diff --git a/.gitignore b/.gitignore
index 47aeea1e6..807d68fdf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
cache/*
+local/config/build.properties
diff --git a/core/lib/Thelia/Model/map/AccessoryTableMap.php b/core/lib/Thelia/Model/map/AccessoryTableMap.php
index 88441de7e..751c6e424 100644
--- a/core/lib/Thelia/Model/map/AccessoryTableMap.php
+++ b/core/lib/Thelia/Model/map/AccessoryTableMap.php
@@ -43,8 +43,8 @@ class AccessoryTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('PRODUCT_ID', 'ProductId', 'INTEGER', true, null, null);
- $this->addColumn('ACCESSORY', 'Accessory', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addForeignKey('ACCESSORY', 'Accessory', 'INTEGER', 'product', 'ID', true, null, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
@@ -56,8 +56,8 @@ class AccessoryTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('accessory' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // AccessoryTableMap
diff --git a/core/lib/Thelia/Model/map/AddressTableMap.php b/core/lib/Thelia/Model/map/AddressTableMap.php
index 32f1ec979..ea9041a94 100644
--- a/core/lib/Thelia/Model/map/AddressTableMap.php
+++ b/core/lib/Thelia/Model/map/AddressTableMap.php
@@ -44,8 +44,8 @@ class AddressTableMap extends TableMap
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
- $this->addColumn('CUSTOMER_ID', 'CustomerId', 'INTEGER', true, null, null);
- $this->addColumn('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', false, null, null);
+ $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
+ $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
$this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
@@ -66,8 +66,8 @@ class AddressTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::ONE_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::ONE_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ $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);
} // buildRelations()
} // AddressTableMap
diff --git a/core/lib/Thelia/Model/map/AdminGroupTableMap.php b/core/lib/Thelia/Model/map/AdminGroupTableMap.php
index 7c27e2afa..9acd8ad4f 100644
--- a/core/lib/Thelia/Model/map/AdminGroupTableMap.php
+++ b/core/lib/Thelia/Model/map/AdminGroupTableMap.php
@@ -43,8 +43,8 @@ class AdminGroupTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('GROUP_ID', 'GroupId', 'INTEGER', false, null, null);
- $this->addColumn('ADMIN_ID', 'AdminId', 'INTEGER', false, 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);
// validators
@@ -55,8 +55,8 @@ class AdminGroupTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Admin', 'Thelia\\Model\\Admin', RelationMap::ONE_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::ONE_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // AdminGroupTableMap
diff --git a/core/lib/Thelia/Model/map/AdminTableMap.php b/core/lib/Thelia/Model/map/AdminTableMap.php
index d2824989d..4240335a3 100644
--- a/core/lib/Thelia/Model/map/AdminTableMap.php
+++ b/core/lib/Thelia/Model/map/AdminTableMap.php
@@ -42,7 +42,7 @@ class AdminTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'admin_group', 'ADMIN_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 100, null);
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 100, null);
$this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 100, null);
@@ -59,7 +59,7 @@ class AdminTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::MANY_TO_ONE, array('id' => 'admin_id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'admin_id', ), 'CASCADE', null, 'AdminGroups');
} // buildRelations()
} // AdminTableMap
diff --git a/core/lib/Thelia/Model/map/AreaTableMap.php b/core/lib/Thelia/Model/map/AreaTableMap.php
index 535ea119b..28c4e3cc8 100644
--- a/core/lib/Thelia/Model/map/AreaTableMap.php
+++ b/core/lib/Thelia/Model/map/AreaTableMap.php
@@ -42,8 +42,7 @@ class AreaTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country', 'AREA_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'delivzone', 'AREA_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('NAME', 'Name', 'VARCHAR', true, 100, null);
$this->addColumn('UNIT', 'Unit', 'FLOAT', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -56,8 +55,8 @@ class AreaTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('Delivzone', 'Thelia\\Model\\Delivzone', RelationMap::MANY_TO_ONE, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT');
+ $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');
} // buildRelations()
} // AreaTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php b/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php
index c3bf6e99e..8aca46635 100644
--- a/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php
+++ b/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php
@@ -43,7 +43,7 @@ class AttributeAvDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER', true, null, null);
+ $this->addForeignKey('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER', 'attribute_av', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class AttributeAvDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::ONE_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // AttributeAvDescTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeAvTableMap.php b/core/lib/Thelia/Model/map/AttributeAvTableMap.php
index be7824f2b..4f1a03b92 100644
--- a/core/lib/Thelia/Model/map/AttributeAvTableMap.php
+++ b/core/lib/Thelia/Model/map/AttributeAvTableMap.php
@@ -42,9 +42,8 @@ class AttributeAvTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av_desc', 'ATTRIBUTE_AV_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_combination', 'ATTRIBUTE_AV_ID', true, null, null);
- $this->addColumn('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
@@ -56,9 +55,9 @@ class AttributeAvTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('AttributeAvDesc', 'Thelia\\Model\\AttributeAvDesc', RelationMap::MANY_TO_ONE, array('id' => 'attribute_av_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::MANY_TO_ONE, array('id' => 'attribute_av_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::ONE_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // AttributeAvTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php
index 7e74861ef..eca24088c 100644
--- a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php
+++ b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php
@@ -43,8 +43,8 @@ class AttributeCategoryTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('CATEGORY_ID', 'CategoryId', 'INTEGER', true, null, null);
- $this->addColumn('ATTRIBUTE_ID', 'AttributeId', '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);
// validators
@@ -55,8 +55,8 @@ class AttributeCategoryTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::ONE_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::ONE_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // AttributeCategoryTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php
index 376dc0752..aa52a5702 100644
--- a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php
+++ b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php
@@ -43,9 +43,9 @@ class AttributeCombinationTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addPrimaryKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', true, null, null);
- $this->addPrimaryKey('COMBINATION_ID', 'CombinationId', 'INTEGER', true, null, null);
- $this->addPrimaryKey('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER', true, null, null);
+ $this->addForeignPrimaryKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER' , 'attribute', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('COMBINATION_ID', 'CombinationId', 'INTEGER' , 'combination', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER' , 'attribute_av', 'ID', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
// validators
@@ -56,9 +56,9 @@ class AttributeCombinationTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::ONE_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::ONE_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::ONE_TO_ONE, array('combination_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // AttributeCombinationTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeDescTableMap.php b/core/lib/Thelia/Model/map/AttributeDescTableMap.php
index d23708a00..084523b3a 100644
--- a/core/lib/Thelia/Model/map/AttributeDescTableMap.php
+++ b/core/lib/Thelia/Model/map/AttributeDescTableMap.php
@@ -44,7 +44,7 @@ class AttributeDescTableMap extends TableMap
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
- $this->addColumn('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', true, null, null);
+ $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class AttributeDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::ONE_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // AttributeDescTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeTableMap.php b/core/lib/Thelia/Model/map/AttributeTableMap.php
index 70579d699..d9dd0f1e5 100644
--- a/core/lib/Thelia/Model/map/AttributeTableMap.php
+++ b/core/lib/Thelia/Model/map/AttributeTableMap.php
@@ -42,10 +42,7 @@ class AttributeTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av', 'ATTRIBUTE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_category', 'ATTRIBUTE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_combination', 'ATTRIBUTE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_desc', 'ATTRIBUTE_ID', true, null, null);
+ $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);
@@ -57,10 +54,10 @@ class AttributeTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::MANY_TO_ONE, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::MANY_TO_ONE, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('AttributeDesc', 'Thelia\\Model\\AttributeDesc', RelationMap::MANY_TO_ONE, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // AttributeTableMap
diff --git a/core/lib/Thelia/Model/map/CategoryDescTableMap.php b/core/lib/Thelia/Model/map/CategoryDescTableMap.php
index b29679153..0c32a58d9 100644
--- a/core/lib/Thelia/Model/map/CategoryDescTableMap.php
+++ b/core/lib/Thelia/Model/map/CategoryDescTableMap.php
@@ -43,7 +43,7 @@ class CategoryDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('CATEGORY_ID', 'CategoryId', 'INTEGER', true, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
@@ -59,7 +59,7 @@ class CategoryDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::ONE_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CategoryDescTableMap
diff --git a/core/lib/Thelia/Model/map/CategoryTableMap.php b/core/lib/Thelia/Model/map/CategoryTableMap.php
index 8618585f9..2231277ac 100644
--- a/core/lib/Thelia/Model/map/CategoryTableMap.php
+++ b/core/lib/Thelia/Model/map/CategoryTableMap.php
@@ -42,14 +42,7 @@ class CategoryTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_category', 'CATEGORY_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category_desc', 'CATEGORY_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_assoc', 'CATEGORY_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'CATEGORY_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_category', 'CATEGORY_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'CATEGORY_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product_category', 'CATEGORY_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'rewriting', 'CATEGORY_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
$this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
$this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null);
@@ -64,14 +57,14 @@ class CategoryTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::MANY_TO_ONE, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('CategoryDesc', 'Thelia\\Model\\CategoryDesc', RelationMap::MANY_TO_ONE, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::MANY_TO_ONE, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::MANY_TO_ONE, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::MANY_TO_ONE, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::MANY_TO_ONE, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // CategoryTableMap
diff --git a/core/lib/Thelia/Model/map/CombinationTableMap.php b/core/lib/Thelia/Model/map/CombinationTableMap.php
index c40ad185e..5b741dcc4 100644
--- a/core/lib/Thelia/Model/map/CombinationTableMap.php
+++ b/core/lib/Thelia/Model/map/CombinationTableMap.php
@@ -42,8 +42,7 @@ class CombinationTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_combination', 'COMBINATION_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'stock', 'COMBINATION_ID', true, null, null);
+ $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);
@@ -55,8 +54,8 @@ class CombinationTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::MANY_TO_ONE, array('id' => 'combination_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::MANY_TO_ONE, array('id' => 'combination_id', ), 'SET NULL', 'RESTRICT');
+ $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');
} // buildRelations()
} // CombinationTableMap
diff --git a/core/lib/Thelia/Model/map/ConfigDescTableMap.php b/core/lib/Thelia/Model/map/ConfigDescTableMap.php
index b08c07bdb..d0176ff14 100644
--- a/core/lib/Thelia/Model/map/ConfigDescTableMap.php
+++ b/core/lib/Thelia/Model/map/ConfigDescTableMap.php
@@ -43,7 +43,7 @@ class ConfigDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('CONFIG_ID', 'ConfigId', 'INTEGER', true, null, null);
+ $this->addForeignKey('CONFIG_ID', 'ConfigId', 'INTEGER', 'config', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class ConfigDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Config', 'Thelia\\Model\\Config', RelationMap::ONE_TO_ONE, array('config_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Config', 'Thelia\\Model\\Config', RelationMap::MANY_TO_ONE, array('config_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // ConfigDescTableMap
diff --git a/core/lib/Thelia/Model/map/ConfigTableMap.php b/core/lib/Thelia/Model/map/ConfigTableMap.php
index 55bd11891..705a0ca0c 100644
--- a/core/lib/Thelia/Model/map/ConfigTableMap.php
+++ b/core/lib/Thelia/Model/map/ConfigTableMap.php
@@ -42,7 +42,7 @@ class ConfigTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'config_desc', 'CONFIG_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('NAME', 'Name', 'VARCHAR', true, 255, null);
$this->addColumn('VALUE', 'Value', 'VARCHAR', true, 255, null);
$this->addColumn('SECURE', 'Secure', 'TINYINT', true, null, 1);
@@ -57,7 +57,7 @@ class ConfigTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('ConfigDesc', 'Thelia\\Model\\ConfigDesc', RelationMap::MANY_TO_ONE, array('id' => 'config_id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('ConfigDesc', 'Thelia\\Model\\ConfigDesc', RelationMap::ONE_TO_MANY, array('id' => 'config_id', ), 'CASCADE', null, 'ConfigDescs');
} // buildRelations()
} // ConfigTableMap
diff --git a/core/lib/Thelia/Model/map/ContentAssocTableMap.php b/core/lib/Thelia/Model/map/ContentAssocTableMap.php
index 9c5e1e23d..0650f7d4c 100644
--- a/core/lib/Thelia/Model/map/ContentAssocTableMap.php
+++ b/core/lib/Thelia/Model/map/ContentAssocTableMap.php
@@ -43,9 +43,9 @@ class ContentAssocTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('CATEGORY_ID', 'CategoryId', 'INTEGER', false, null, null);
- $this->addColumn('PRODUCT_ID', 'ProductId', 'INTEGER', false, null, null);
- $this->addColumn('CONTENT_ID', 'ContentId', 'INTEGER', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
@@ -57,9 +57,9 @@ class ContentAssocTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::ONE_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::ONE_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // ContentAssocTableMap
diff --git a/core/lib/Thelia/Model/map/ContentDescTableMap.php b/core/lib/Thelia/Model/map/ContentDescTableMap.php
index 1efde7ebe..489d7a478 100644
--- a/core/lib/Thelia/Model/map/ContentDescTableMap.php
+++ b/core/lib/Thelia/Model/map/ContentDescTableMap.php
@@ -43,7 +43,7 @@ class ContentDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('CONTENT_ID', 'ContentId', 'INTEGER', true, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -59,7 +59,7 @@ class ContentDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::ONE_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // ContentDescTableMap
diff --git a/core/lib/Thelia/Model/map/ContentFolderTableMap.php b/core/lib/Thelia/Model/map/ContentFolderTableMap.php
index 548f28e90..f0fe4a58a 100644
--- a/core/lib/Thelia/Model/map/ContentFolderTableMap.php
+++ b/core/lib/Thelia/Model/map/ContentFolderTableMap.php
@@ -42,8 +42,8 @@ class ContentFolderTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(false);
// columns
- $this->addPrimaryKey('CONTENT_ID', 'ContentId', 'INTEGER', true, null, null);
- $this->addPrimaryKey('FOLDER_ID', 'FolderId', 'INTEGER', true, null, null);
+ $this->addForeignPrimaryKey('CONTENT_ID', 'ContentId', 'INTEGER' , 'content', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('FOLDER_ID', 'FolderId', 'INTEGER' , 'folder', 'ID', true, null, null);
// validators
} // initialize()
@@ -52,8 +52,8 @@ class ContentFolderTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::ONE_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::ONE_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // ContentFolderTableMap
diff --git a/core/lib/Thelia/Model/map/ContentTableMap.php b/core/lib/Thelia/Model/map/ContentTableMap.php
index fff6d7fd1..66712b485 100644
--- a/core/lib/Thelia/Model/map/ContentTableMap.php
+++ b/core/lib/Thelia/Model/map/ContentTableMap.php
@@ -42,12 +42,7 @@ class ContentTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_assoc', 'CONTENT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_desc', 'CONTENT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_folder', 'CONTENT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'CONTENT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'CONTENT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'rewriting', 'CONTENT_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -60,12 +55,12 @@ class ContentTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::MANY_TO_ONE, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ContentDesc', 'Thelia\\Model\\ContentDesc', RelationMap::MANY_TO_ONE, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::MANY_TO_ONE, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::MANY_TO_ONE, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // ContentTableMap
diff --git a/core/lib/Thelia/Model/map/CountryDescTableMap.php b/core/lib/Thelia/Model/map/CountryDescTableMap.php
index ee9345910..fdc6dce94 100644
--- a/core/lib/Thelia/Model/map/CountryDescTableMap.php
+++ b/core/lib/Thelia/Model/map/CountryDescTableMap.php
@@ -43,7 +43,7 @@ class CountryDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
+ $this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class CountryDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::ONE_TO_ONE, array('country_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CountryDescTableMap
diff --git a/core/lib/Thelia/Model/map/CountryTableMap.php b/core/lib/Thelia/Model/map/CountryTableMap.php
index a189a077a..c8c11993c 100644
--- a/core/lib/Thelia/Model/map/CountryTableMap.php
+++ b/core/lib/Thelia/Model/map/CountryTableMap.php
@@ -42,9 +42,8 @@ class CountryTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(false);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country_desc', 'COUNTRY_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule_country', 'COUNTRY_ID', true, null, null);
- $this->addColumn('AREA_ID', 'AreaId', 'INTEGER', false, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null);
$this->addColumn('ISOCODE', 'Isocode', 'VARCHAR', true, 4, null);
$this->addColumn('ISOALPHA2', 'Isoalpha2', 'VARCHAR', false, 2, null);
$this->addColumn('ISOALPHA3', 'Isoalpha3', 'VARCHAR', false, 4, null);
@@ -58,9 +57,9 @@ class CountryTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('CountryDesc', 'Thelia\\Model\\CountryDesc', RelationMap::MANY_TO_ONE, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::MANY_TO_ONE, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::ONE_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $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');
} // buildRelations()
} // CountryTableMap
diff --git a/core/lib/Thelia/Model/map/CouponOrderTableMap.php b/core/lib/Thelia/Model/map/CouponOrderTableMap.php
index 30c3da13c..a769d0a95 100644
--- a/core/lib/Thelia/Model/map/CouponOrderTableMap.php
+++ b/core/lib/Thelia/Model/map/CouponOrderTableMap.php
@@ -43,7 +43,7 @@ class CouponOrderTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('ORDER_ID', 'OrderId', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
$this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
$this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -56,7 +56,7 @@ class CouponOrderTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CouponOrderTableMap
diff --git a/core/lib/Thelia/Model/map/CouponRuleTableMap.php b/core/lib/Thelia/Model/map/CouponRuleTableMap.php
index 180da0103..00eb5b987 100644
--- a/core/lib/Thelia/Model/map/CouponRuleTableMap.php
+++ b/core/lib/Thelia/Model/map/CouponRuleTableMap.php
@@ -43,7 +43,7 @@ class CouponRuleTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('COUPON_ID', 'CouponId', 'INTEGER', true, null, null);
+ $this->addForeignKey('COUPON_ID', 'CouponId', 'INTEGER', 'coupon', 'ID', true, null, null);
$this->addColumn('CONTROLLER', 'Controller', 'VARCHAR', false, 255, null);
$this->addColumn('OPERATION', 'Operation', 'VARCHAR', false, 255, null);
$this->addColumn('VALUE', 'Value', 'FLOAT', false, null, null);
@@ -57,7 +57,7 @@ class CouponRuleTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Coupon', 'Thelia\\Model\\Coupon', RelationMap::ONE_TO_ONE, array('coupon_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Coupon', 'Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('coupon_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CouponRuleTableMap
diff --git a/core/lib/Thelia/Model/map/CouponTableMap.php b/core/lib/Thelia/Model/map/CouponTableMap.php
index c29e31541..c9a26eecf 100644
--- a/core/lib/Thelia/Model/map/CouponTableMap.php
+++ b/core/lib/Thelia/Model/map/CouponTableMap.php
@@ -42,7 +42,7 @@ class CouponTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'coupon_rule', 'COUPON_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
$this->addColumn('ACTION', 'Action', 'VARCHAR', true, 255, null);
$this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
@@ -60,7 +60,7 @@ class CouponTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('CouponRule', 'Thelia\\Model\\CouponRule', RelationMap::MANY_TO_ONE, array('id' => 'coupon_id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('CouponRule', 'Thelia\\Model\\CouponRule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', null, 'CouponRules');
} // buildRelations()
} // CouponTableMap
diff --git a/core/lib/Thelia/Model/map/CurrencyTableMap.php b/core/lib/Thelia/Model/map/CurrencyTableMap.php
index aef629975..4a6b80439 100644
--- a/core/lib/Thelia/Model/map/CurrencyTableMap.php
+++ b/core/lib/Thelia/Model/map/CurrencyTableMap.php
@@ -42,7 +42,7 @@ class CurrencyTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order', 'CURRENCY_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('NAME', 'Name', 'VARCHAR', false, 45, null);
$this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
$this->addColumn('SYMBOL', 'Symbol', 'VARCHAR', false, 45, null);
@@ -58,7 +58,7 @@ class CurrencyTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', null, 'Orders');
} // buildRelations()
} // CurrencyTableMap
diff --git a/core/lib/Thelia/Model/map/CustomerTableMap.php b/core/lib/Thelia/Model/map/CustomerTableMap.php
index 51ab78480..68f2d52af 100644
--- a/core/lib/Thelia/Model/map/CustomerTableMap.php
+++ b/core/lib/Thelia/Model/map/CustomerTableMap.php
@@ -42,10 +42,9 @@ class CustomerTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'address', 'CUSTOMER_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order', 'CUSTOMER_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, null);
- $this->addColumn('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', false, null, null);
+ $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
$this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
@@ -75,9 +74,9 @@ class CustomerTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::MANY_TO_ONE, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::ONE_TO_ONE, array('customer_title_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $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');
} // buildRelations()
} // CustomerTableMap
diff --git a/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php
index 2346801d0..3e2f4408d 100644
--- a/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php
+++ b/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php
@@ -43,7 +43,7 @@ class CustomerTitleDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', true, null, null);
+ $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null);
$this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null);
@@ -57,7 +57,7 @@ class CustomerTitleDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::ONE_TO_ONE, array('customer_title_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CustomerTitleDescTableMap
diff --git a/core/lib/Thelia/Model/map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleTableMap.php
index fbc870a93..6de110a47 100644
--- a/core/lib/Thelia/Model/map/CustomerTitleTableMap.php
+++ b/core/lib/Thelia/Model/map/CustomerTitleTableMap.php
@@ -42,9 +42,7 @@ class CustomerTitleTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'address', 'CUSTOMER_TITLE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer', 'CUSTOMER_TITLE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer_title_desc', 'CUSTOMER_TITLE_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('DEFAULT_UTILITY', 'DefaultUtility', 'INTEGER', true, null, 0);
$this->addColumn('POSITION', 'Position', 'VARCHAR', true, 45, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -57,9 +55,9 @@ class CustomerTitleTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::MANY_TO_ONE, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT');
- $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('id' => 'customer_title_id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('CustomerTitleDesc', 'Thelia\\Model\\CustomerTitleDesc', RelationMap::MANY_TO_ONE, array('id' => 'customer_title_id', ), 'CASCADE', null);
+ $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('CustomerTitleDesc', 'Thelia\\Model\\CustomerTitleDesc', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'CASCADE', null, 'CustomerTitleDescs');
} // buildRelations()
} // CustomerTitleTableMap
diff --git a/core/lib/Thelia/Model/map/DelivzoneTableMap.php b/core/lib/Thelia/Model/map/DelivzoneTableMap.php
index 18b8e3fe7..86c4fe5e4 100644
--- a/core/lib/Thelia/Model/map/DelivzoneTableMap.php
+++ b/core/lib/Thelia/Model/map/DelivzoneTableMap.php
@@ -43,7 +43,7 @@ class DelivzoneTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('AREA_ID', 'AreaId', 'INTEGER', false, 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);
@@ -55,7 +55,7 @@ class DelivzoneTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::ONE_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', null);
} // buildRelations()
} // DelivzoneTableMap
diff --git a/core/lib/Thelia/Model/map/DocumentDescTableMap.php b/core/lib/Thelia/Model/map/DocumentDescTableMap.php
index b7d544c57..f181e3421 100644
--- a/core/lib/Thelia/Model/map/DocumentDescTableMap.php
+++ b/core/lib/Thelia/Model/map/DocumentDescTableMap.php
@@ -43,7 +43,7 @@ class DocumentDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('DOCUMENT_ID', 'DocumentId', 'INTEGER', true, null, null);
+ $this->addForeignKey('DOCUMENT_ID', 'DocumentId', 'INTEGER', 'document', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class DocumentDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_ONE, array('document_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('document_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // DocumentDescTableMap
diff --git a/core/lib/Thelia/Model/map/DocumentTableMap.php b/core/lib/Thelia/Model/map/DocumentTableMap.php
index 5bbb25f83..b305f8a00 100644
--- a/core/lib/Thelia/Model/map/DocumentTableMap.php
+++ b/core/lib/Thelia/Model/map/DocumentTableMap.php
@@ -42,11 +42,11 @@ class DocumentTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document_desc', 'DOCUMENT_ID', true, null, null);
- $this->addColumn('PRODUCT_ID', 'ProductId', 'INTEGER', false, null, null);
- $this->addColumn('CATEGORY_ID', 'CategoryId', 'INTEGER', false, null, null);
- $this->addColumn('FOLDER_ID', 'FolderId', 'INTEGER', false, null, null);
- $this->addColumn('CONTENT_ID', 'ContentId', 'INTEGER', false, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
$this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -59,11 +59,11 @@ class DocumentTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('DocumentDesc', 'Thelia\\Model\\DocumentDesc', RelationMap::MANY_TO_ONE, array('id' => 'document_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::ONE_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::ONE_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::ONE_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // DocumentTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php b/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php
index 85e7aec0c..001844e65 100644
--- a/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php
+++ b/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php
@@ -43,7 +43,7 @@ class FeatureAvDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', true, null, null);
+ $this->addForeignKey('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', 'feature_av', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', true, null, null);
@@ -56,7 +56,7 @@ class FeatureAvDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::ONE_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // FeatureAvDescTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureAvTableMap.php b/core/lib/Thelia/Model/map/FeatureAvTableMap.php
index 79305a5aa..fa56c5b6e 100644
--- a/core/lib/Thelia/Model/map/FeatureAvTableMap.php
+++ b/core/lib/Thelia/Model/map/FeatureAvTableMap.php
@@ -42,9 +42,8 @@ class FeatureAvTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av_desc', 'FEATURE_AV_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_prod', 'FEATURE_AV_ID', true, null, null);
- $this->addColumn('FEATURE_ID', 'FeatureId', 'INTEGER', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
// validators
@@ -55,9 +54,9 @@ class FeatureAvTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('FeatureAvDesc', 'Thelia\\Model\\FeatureAvDesc', RelationMap::MANY_TO_ONE, array('id' => 'feature_av_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::MANY_TO_ONE, array('id' => 'feature_av_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::ONE_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // FeatureAvTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php
index c40c25a02..2aaedcba4 100644
--- a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php
+++ b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php
@@ -43,8 +43,8 @@ class FeatureCategoryTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('FEATURE_ID', 'FeatureId', 'INTEGER', true, null, null);
- $this->addColumn('CATEGORY_ID', 'CategoryId', '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);
// validators
@@ -55,8 +55,8 @@ class FeatureCategoryTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::ONE_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::ONE_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // FeatureCategoryTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureDescTableMap.php b/core/lib/Thelia/Model/map/FeatureDescTableMap.php
index 93ede3bcc..dbff3c642 100644
--- a/core/lib/Thelia/Model/map/FeatureDescTableMap.php
+++ b/core/lib/Thelia/Model/map/FeatureDescTableMap.php
@@ -43,7 +43,7 @@ class FeatureDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('FEATURE_ID', 'FeatureId', 'INTEGER', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class FeatureDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::ONE_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // FeatureDescTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureProdTableMap.php b/core/lib/Thelia/Model/map/FeatureProdTableMap.php
index 8a70fd67f..24cde96d3 100644
--- a/core/lib/Thelia/Model/map/FeatureProdTableMap.php
+++ b/core/lib/Thelia/Model/map/FeatureProdTableMap.php
@@ -43,9 +43,9 @@ class FeatureProdTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('PRODUCT_ID', 'ProductId', 'INTEGER', true, null, null);
- $this->addColumn('FEATURE_ID', 'FeatureId', 'INTEGER', true, null, null);
- $this->addColumn('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', false, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
+ $this->addForeignKey('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', 'feature_av', 'ID', false, null, null);
$this->addColumn('DEFAULT_UTILITY', 'DefaultUtility', 'VARCHAR', false, 255, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -58,9 +58,9 @@ class FeatureProdTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::ONE_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::ONE_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // FeatureProdTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureTableMap.php b/core/lib/Thelia/Model/map/FeatureTableMap.php
index fb3a4fb7d..4378e8489 100644
--- a/core/lib/Thelia/Model/map/FeatureTableMap.php
+++ b/core/lib/Thelia/Model/map/FeatureTableMap.php
@@ -42,10 +42,7 @@ class FeatureTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av', 'FEATURE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_category', 'FEATURE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_desc', 'FEATURE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_prod', 'FEATURE_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('VISIBLE', 'Visible', 'INTEGER', false, null, 0);
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -58,10 +55,10 @@ class FeatureTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::MANY_TO_ONE, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('FeatureDesc', 'Thelia\\Model\\FeatureDesc', RelationMap::MANY_TO_ONE, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::MANY_TO_ONE, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // FeatureTableMap
diff --git a/core/lib/Thelia/Model/map/FolderDescTableMap.php b/core/lib/Thelia/Model/map/FolderDescTableMap.php
index 5ef3a7bf2..40f5aa1e3 100644
--- a/core/lib/Thelia/Model/map/FolderDescTableMap.php
+++ b/core/lib/Thelia/Model/map/FolderDescTableMap.php
@@ -43,7 +43,7 @@ class FolderDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('FOLDER_ID', 'FolderId', 'INTEGER', true, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -59,7 +59,7 @@ class FolderDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::ONE_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // FolderDescTableMap
diff --git a/core/lib/Thelia/Model/map/FolderTableMap.php b/core/lib/Thelia/Model/map/FolderTableMap.php
index d6cf2a3c3..bf0513351 100644
--- a/core/lib/Thelia/Model/map/FolderTableMap.php
+++ b/core/lib/Thelia/Model/map/FolderTableMap.php
@@ -42,11 +42,7 @@ class FolderTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_folder', 'FOLDER_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'FOLDER_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder_desc', 'FOLDER_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'FOLDER_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'rewriting', 'FOLDER_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null);
$this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
$this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
@@ -61,11 +57,11 @@ class FolderTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::MANY_TO_ONE, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('FolderDesc', 'Thelia\\Model\\FolderDesc', RelationMap::MANY_TO_ONE, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::MANY_TO_ONE, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // FolderTableMap
diff --git a/core/lib/Thelia/Model/map/GroupDescTableMap.php b/core/lib/Thelia/Model/map/GroupDescTableMap.php
index f29a75c72..543b7e66a 100644
--- a/core/lib/Thelia/Model/map/GroupDescTableMap.php
+++ b/core/lib/Thelia/Model/map/GroupDescTableMap.php
@@ -43,7 +43,7 @@ class GroupDescTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('GROUP_ID', 'GroupId', 'INTEGER', true, null, null);
+ $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class GroupDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::ONE_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // GroupDescTableMap
diff --git a/core/lib/Thelia/Model/map/GroupModuleTableMap.php b/core/lib/Thelia/Model/map/GroupModuleTableMap.php
index 551e029b9..0224f234c 100644
--- a/core/lib/Thelia/Model/map/GroupModuleTableMap.php
+++ b/core/lib/Thelia/Model/map/GroupModuleTableMap.php
@@ -43,8 +43,8 @@ class GroupModuleTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('GROUP_ID', 'GroupId', 'INTEGER', true, null, null);
- $this->addColumn('MODULE_ID', 'ModuleId', 'INTEGER', false, null, null);
+ $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null);
+ $this->addForeignKey('MODULE_ID', 'ModuleId', 'INTEGER', 'module', 'ID', false, null, null);
$this->addColumn('ACCESS', 'Access', 'TINYINT', false, null, 0);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
@@ -56,8 +56,8 @@ class GroupModuleTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::ONE_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'CASCADE');
- $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::ONE_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // GroupModuleTableMap
diff --git a/core/lib/Thelia/Model/map/GroupResourceTableMap.php b/core/lib/Thelia/Model/map/GroupResourceTableMap.php
index 7d4325d7b..ba5d42e8c 100644
--- a/core/lib/Thelia/Model/map/GroupResourceTableMap.php
+++ b/core/lib/Thelia/Model/map/GroupResourceTableMap.php
@@ -43,8 +43,8 @@ class GroupResourceTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('GROUP_ID', 'GroupId', 'INTEGER', true, null, null);
- $this->addColumn('RESOURCE_ID', 'ResourceId', 'INTEGER', true, null, null);
+ $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null);
+ $this->addForeignKey('RESOURCE_ID', 'ResourceId', 'INTEGER', 'resource', 'ID', true, null, null);
$this->addColumn('READ', 'Read', 'TINYINT', false, null, 0);
$this->addColumn('WRITE', 'Write', 'TINYINT', false, null, 0);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -57,8 +57,8 @@ class GroupResourceTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::ONE_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::ONE_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // GroupResourceTableMap
diff --git a/core/lib/Thelia/Model/map/GroupTableMap.php b/core/lib/Thelia/Model/map/GroupTableMap.php
index 48f209c62..7b38a8781 100644
--- a/core/lib/Thelia/Model/map/GroupTableMap.php
+++ b/core/lib/Thelia/Model/map/GroupTableMap.php
@@ -42,10 +42,7 @@ class GroupTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'admin_group', 'GROUP_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group_desc', 'GROUP_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group_module', 'GROUP_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group_resource', 'GROUP_ID', true, null, null);
+ $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);
@@ -57,10 +54,10 @@ class GroupTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::MANY_TO_ONE, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('GroupDesc', 'Thelia\\Model\\GroupDesc', RelationMap::MANY_TO_ONE, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('GroupModule', 'Thelia\\Model\\GroupModule', RelationMap::MANY_TO_ONE, array('id' => 'group_id', ), 'CASCADE', 'CASCADE');
- $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::MANY_TO_ONE, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT');
+ $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('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()
} // GroupTableMap
diff --git a/core/lib/Thelia/Model/map/ImageDescTableMap.php b/core/lib/Thelia/Model/map/ImageDescTableMap.php
index 5dcd56ab9..9aa41ad64 100644
--- a/core/lib/Thelia/Model/map/ImageDescTableMap.php
+++ b/core/lib/Thelia/Model/map/ImageDescTableMap.php
@@ -43,7 +43,7 @@ class ImageDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('IMAGE_ID', 'ImageId', 'INTEGER', false, null, null);
+ $this->addForeignKey('IMAGE_ID', 'ImageId', 'INTEGER', 'image', 'ID', false, null, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
@@ -57,7 +57,7 @@ class ImageDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_ONE, array('image_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('image_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // ImageDescTableMap
diff --git a/core/lib/Thelia/Model/map/ImageTableMap.php b/core/lib/Thelia/Model/map/ImageTableMap.php
index 4af79b401..d53b7e180 100644
--- a/core/lib/Thelia/Model/map/ImageTableMap.php
+++ b/core/lib/Thelia/Model/map/ImageTableMap.php
@@ -42,11 +42,11 @@ class ImageTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image_desc', 'IMAGE_ID', true, null, null);
- $this->addColumn('PRODUCT_ID', 'ProductId', 'INTEGER', false, null, null);
- $this->addColumn('CATEGORY_ID', 'CategoryId', 'INTEGER', false, null, null);
- $this->addColumn('FOLDER_ID', 'FolderId', 'INTEGER', false, null, null);
- $this->addColumn('CONTENT_ID', 'ContentId', 'INTEGER', false, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
$this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -59,11 +59,11 @@ class ImageTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('ImageDesc', 'Thelia\\Model\\ImageDesc', RelationMap::MANY_TO_ONE, array('id' => 'image_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::ONE_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::ONE_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::ONE_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // ImageTableMap
diff --git a/core/lib/Thelia/Model/map/MessageDescTableMap.php b/core/lib/Thelia/Model/map/MessageDescTableMap.php
index 0fecb9f11..f4b6705d4 100644
--- a/core/lib/Thelia/Model/map/MessageDescTableMap.php
+++ b/core/lib/Thelia/Model/map/MessageDescTableMap.php
@@ -43,7 +43,7 @@ class MessageDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('MESSAGE_ID', 'MessageId', 'INTEGER', true, null, null);
+ $this->addForeignKey('MESSAGE_ID', 'MessageId', 'INTEGER', 'message', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 45, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class MessageDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Message', 'Thelia\\Model\\Message', RelationMap::ONE_TO_ONE, array('message_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Message', 'Thelia\\Model\\Message', RelationMap::MANY_TO_ONE, array('message_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // MessageDescTableMap
diff --git a/core/lib/Thelia/Model/map/MessageTableMap.php b/core/lib/Thelia/Model/map/MessageTableMap.php
index 1153120b9..06e7c34eb 100644
--- a/core/lib/Thelia/Model/map/MessageTableMap.php
+++ b/core/lib/Thelia/Model/map/MessageTableMap.php
@@ -42,7 +42,7 @@ class MessageTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message_desc', 'MESSAGE_ID', true, null, null);
+ $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);
@@ -55,7 +55,7 @@ class MessageTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('MessageDesc', 'Thelia\\Model\\MessageDesc', RelationMap::MANY_TO_ONE, array('id' => 'message_id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('MessageDesc', 'Thelia\\Model\\MessageDesc', RelationMap::ONE_TO_MANY, array('id' => 'message_id', ), 'CASCADE', null, 'MessageDescs');
} // buildRelations()
} // MessageTableMap
diff --git a/core/lib/Thelia/Model/map/ModuleDescTableMap.php b/core/lib/Thelia/Model/map/ModuleDescTableMap.php
index 09d629f73..529bc408d 100644
--- a/core/lib/Thelia/Model/map/ModuleDescTableMap.php
+++ b/core/lib/Thelia/Model/map/ModuleDescTableMap.php
@@ -43,7 +43,7 @@ class ModuleDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('MODULE_ID', 'ModuleId', 'INTEGER', true, null, null);
+ $this->addForeignKey('MODULE_ID', 'ModuleId', 'INTEGER', 'module', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -59,7 +59,7 @@ class ModuleDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::ONE_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // ModuleDescTableMap
diff --git a/core/lib/Thelia/Model/map/ModuleTableMap.php b/core/lib/Thelia/Model/map/ModuleTableMap.php
index 355d8ff8f..21eb422b7 100644
--- a/core/lib/Thelia/Model/map/ModuleTableMap.php
+++ b/core/lib/Thelia/Model/map/ModuleTableMap.php
@@ -42,8 +42,7 @@ class ModuleTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(false);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group_module', 'MODULE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module_desc', 'MODULE_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('CODE', 'Code', 'VARCHAR', true, 55, null);
$this->addColumn('TYPE', 'Type', 'TINYINT', true, null, null);
$this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null);
@@ -58,8 +57,8 @@ class ModuleTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('GroupModule', 'Thelia\\Model\\GroupModule', RelationMap::MANY_TO_ONE, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ModuleDesc', 'Thelia\\Model\\ModuleDesc', RelationMap::MANY_TO_ONE, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // ModuleTableMap
diff --git a/core/lib/Thelia/Model/map/OrderAddressTableMap.php b/core/lib/Thelia/Model/map/OrderAddressTableMap.php
index 75ace1714..91a63e855 100644
--- a/core/lib/Thelia/Model/map/OrderAddressTableMap.php
+++ b/core/lib/Thelia/Model/map/OrderAddressTableMap.php
@@ -42,8 +42,7 @@ class OrderAddressTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order', 'ADDRESS_INVOICE', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order', 'ADDRESS_DELIVERY', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', false, null, null);
$this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
@@ -65,8 +64,8 @@ class OrderAddressTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('id' => 'address_invoice', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('id' => 'address_delivery', ), 'SET NULL', 'RESTRICT');
+ $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');
} // buildRelations()
} // OrderAddressTableMap
diff --git a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php
index f02ced4da..5c62094ae 100644
--- a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php
+++ b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php
@@ -43,7 +43,7 @@ class OrderFeatureTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null);
$this->addColumn('FEATURE_DESC', 'FeatureDesc', 'VARCHAR', false, 255, null);
$this->addColumn('FEATURE_AV_DESC', 'FeatureAvDesc', 'VARCHAR', false, 255, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -56,7 +56,7 @@ class OrderFeatureTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // OrderFeatureTableMap
diff --git a/core/lib/Thelia/Model/map/OrderProductTableMap.php b/core/lib/Thelia/Model/map/OrderProductTableMap.php
index 2a056aed5..864073c5b 100644
--- a/core/lib/Thelia/Model/map/OrderProductTableMap.php
+++ b/core/lib/Thelia/Model/map/OrderProductTableMap.php
@@ -42,8 +42,8 @@ class OrderProductTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_feature', 'ORDER_PRODUCT_ID', true, null, null);
- $this->addColumn('ORDER_ID', 'OrderId', 'INTEGER', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
$this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -62,8 +62,8 @@ class OrderProductTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('OrderFeature', 'Thelia\\Model\\OrderFeature', RelationMap::MANY_TO_ONE, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // OrderProductTableMap
diff --git a/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php b/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php
index c2496c17b..0e1d342d1 100644
--- a/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php
+++ b/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php
@@ -43,7 +43,7 @@ class OrderStatusDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('STATUS_ID', 'StatusId', 'INTEGER', true, null, null);
+ $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'order_status', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -58,7 +58,7 @@ class OrderStatusDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::ONE_TO_ONE, array('status_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // OrderStatusDescTableMap
diff --git a/core/lib/Thelia/Model/map/OrderStatusTableMap.php b/core/lib/Thelia/Model/map/OrderStatusTableMap.php
index 4b777ae4c..eaf2a978e 100644
--- a/core/lib/Thelia/Model/map/OrderStatusTableMap.php
+++ b/core/lib/Thelia/Model/map/OrderStatusTableMap.php
@@ -42,8 +42,7 @@ class OrderStatusTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order', 'STATUS_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_status_desc', 'STATUS_ID', true, null, null);
+ $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);
@@ -55,8 +54,8 @@ class OrderStatusTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('id' => 'status_id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('OrderStatusDesc', 'Thelia\\Model\\OrderStatusDesc', RelationMap::MANY_TO_ONE, array('id' => 'status_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // OrderStatusTableMap
diff --git a/core/lib/Thelia/Model/map/OrderTableMap.php b/core/lib/Thelia/Model/map/OrderTableMap.php
index 381404341..12e73713d 100644
--- a/core/lib/Thelia/Model/map/OrderTableMap.php
+++ b/core/lib/Thelia/Model/map/OrderTableMap.php
@@ -42,14 +42,13 @@ class OrderTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'coupon_order', 'ORDER_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_product', 'ORDER_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null);
- $this->addColumn('CUSTOMER_ID', 'CustomerId', 'INTEGER', true, null, null);
- $this->addColumn('ADDRESS_INVOICE', 'AddressInvoice', 'INTEGER', false, null, null);
- $this->addColumn('ADDRESS_DELIVERY', 'AddressDelivery', 'INTEGER', false, null, null);
+ $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
+ $this->addForeignKey('ADDRESS_INVOICE', 'AddressInvoice', 'INTEGER', 'order_address', 'ID', false, null, null);
+ $this->addForeignKey('ADDRESS_DELIVERY', 'AddressDelivery', 'INTEGER', 'order_address', 'ID', false, null, null);
$this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', false, null, null);
- $this->addColumn('CURRENCY_ID', 'CurrencyId', 'INTEGER', false, null, null);
+ $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', false, null, null);
$this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', true, null, null);
$this->addColumn('TRANSACTION', 'Transaction', 'VARCHAR', false, 100, null);
$this->addColumn('DELIVERY_NUM', 'DeliveryNum', 'VARCHAR', false, 100, null);
@@ -57,7 +56,7 @@ class OrderTableMap extends TableMap
$this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null);
$this->addColumn('PAYMENT', 'Payment', 'VARCHAR', true, 45, null);
$this->addColumn('CARRIER', 'Carrier', 'VARCHAR', true, 45, null);
- $this->addColumn('STATUS_ID', 'StatusId', 'INTEGER', false, null, 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);
@@ -69,13 +68,13 @@ class OrderTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('CouponOrder', 'Thelia\\Model\\CouponOrder', RelationMap::MANY_TO_ONE, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Currency', 'Thelia\\Model\\Currency', RelationMap::ONE_TO_ONE, array('currency_id' => 'id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::ONE_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('OrderAddress', 'Thelia\\Model\\OrderAddress', RelationMap::ONE_TO_ONE, array('address_invoice' => 'id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('OrderAddress', 'Thelia\\Model\\OrderAddress', RelationMap::ONE_TO_ONE, array('address_delivery' => 'id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::ONE_TO_ONE, array('status_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $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');
} // buildRelations()
} // OrderTableMap
diff --git a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php
index f70458f09..759ac44ab 100644
--- a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php
+++ b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php
@@ -42,8 +42,8 @@ class ProductCategoryTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(false);
// columns
- $this->addPrimaryKey('PRODUCT_ID', 'ProductId', 'INTEGER', true, null, null);
- $this->addPrimaryKey('CATEGORY_ID', 'CategoryId', 'INTEGER', true, null, null);
+ $this->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'INTEGER' , 'product', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('CATEGORY_ID', 'CategoryId', 'INTEGER' , 'category', 'ID', true, null, null);
// validators
} // initialize()
@@ -52,8 +52,8 @@ class ProductCategoryTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::ONE_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // ProductCategoryTableMap
diff --git a/core/lib/Thelia/Model/map/ProductDescTableMap.php b/core/lib/Thelia/Model/map/ProductDescTableMap.php
index f256187e4..1e1300145 100644
--- a/core/lib/Thelia/Model/map/ProductDescTableMap.php
+++ b/core/lib/Thelia/Model/map/ProductDescTableMap.php
@@ -43,7 +43,7 @@ class ProductDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('PRODUCT_ID', 'ProductId', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
@@ -59,7 +59,7 @@ class ProductDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // ProductDescTableMap
diff --git a/core/lib/Thelia/Model/map/ProductTableMap.php b/core/lib/Thelia/Model/map/ProductTableMap.php
index 7c9fc36cb..15ed9a9d3 100644
--- a/core/lib/Thelia/Model/map/ProductTableMap.php
+++ b/core/lib/Thelia/Model/map/ProductTableMap.php
@@ -42,17 +42,8 @@ class ProductTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'accessory', 'PRODUCT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'accessory', 'ACCESSORY', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_assoc', 'PRODUCT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'PRODUCT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_prod', 'PRODUCT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'PRODUCT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product_category', 'PRODUCT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product_desc', 'PRODUCT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'rewriting', 'PRODUCT_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'stock', 'PRODUCT_ID', true, null, null);
- $this->addColumn('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', false, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
$this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null);
$this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
$this->addColumn('PRICE2', 'Price2', 'FLOAT', false, null, null);
@@ -73,17 +64,17 @@ class ProductTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Accessory', 'Thelia\\Model\\Accessory', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Accessory', 'Thelia\\Model\\Accessory', RelationMap::MANY_TO_ONE, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ProductDesc', 'Thelia\\Model\\ProductDesc', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::MANY_TO_ONE, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::ONE_TO_ONE, array('tax_rule_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $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');
} // buildRelations()
} // ProductTableMap
diff --git a/core/lib/Thelia/Model/map/ResourceDescTableMap.php b/core/lib/Thelia/Model/map/ResourceDescTableMap.php
index 15e024b8b..1a0ec7b29 100644
--- a/core/lib/Thelia/Model/map/ResourceDescTableMap.php
+++ b/core/lib/Thelia/Model/map/ResourceDescTableMap.php
@@ -43,7 +43,7 @@ class ResourceDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('RESOURCE_ID', 'ResourceId', 'INTEGER', true, null, null);
+ $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);
@@ -56,7 +56,7 @@ class ResourceDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::ONE_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // ResourceDescTableMap
diff --git a/core/lib/Thelia/Model/map/ResourceTableMap.php b/core/lib/Thelia/Model/map/ResourceTableMap.php
index 6e7923324..d2a07cfd2 100644
--- a/core/lib/Thelia/Model/map/ResourceTableMap.php
+++ b/core/lib/Thelia/Model/map/ResourceTableMap.php
@@ -42,8 +42,7 @@ class ResourceTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group_resource', 'RESOURCE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'resource_desc', 'RESOURCE_ID', true, null, null);
+ $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', false, null, null);
@@ -55,8 +54,8 @@ class ResourceTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::MANY_TO_ONE, array('id' => 'resource_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('ResourceDesc', 'Thelia\\Model\\ResourceDesc', RelationMap::MANY_TO_ONE, array('id' => 'resource_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // ResourceTableMap
diff --git a/core/lib/Thelia/Model/map/RewritingTableMap.php b/core/lib/Thelia/Model/map/RewritingTableMap.php
index 71c300d78..e895a0181 100644
--- a/core/lib/Thelia/Model/map/RewritingTableMap.php
+++ b/core/lib/Thelia/Model/map/RewritingTableMap.php
@@ -44,10 +44,10 @@ class RewritingTableMap extends TableMap
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null);
- $this->addColumn('PRODUCT_ID', 'ProductId', 'INTEGER', false, null, null);
- $this->addColumn('CATEGORY_ID', 'CategoryId', 'INTEGER', false, null, null);
- $this->addColumn('FOLDER_ID', 'FolderId', 'INTEGER', false, null, null);
- $this->addColumn('CONTENT_ID', 'ContentId', 'INTEGER', false, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
// validators
@@ -58,10 +58,10 @@ class RewritingTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::ONE_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::ONE_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::ONE_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // RewritingTableMap
diff --git a/core/lib/Thelia/Model/map/StockTableMap.php b/core/lib/Thelia/Model/map/StockTableMap.php
index 3ee704db5..b4aa0cab1 100644
--- a/core/lib/Thelia/Model/map/StockTableMap.php
+++ b/core/lib/Thelia/Model/map/StockTableMap.php
@@ -43,8 +43,8 @@ class StockTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('COMBINATION_ID', 'CombinationId', 'INTEGER', false, null, null);
- $this->addColumn('PRODUCT_ID', 'ProductId', 'INTEGER', true, null, null);
+ $this->addForeignKey('COMBINATION_ID', 'CombinationId', 'INTEGER', 'combination', 'ID', false, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
$this->addColumn('INCREASE', 'Increase', 'FLOAT', false, null, null);
$this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
@@ -57,8 +57,8 @@ class StockTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::ONE_TO_ONE, array('combination_id' => 'id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // StockTableMap
diff --git a/core/lib/Thelia/Model/map/TaxDescTableMap.php b/core/lib/Thelia/Model/map/TaxDescTableMap.php
index ed8ee54c5..767a73cac 100644
--- a/core/lib/Thelia/Model/map/TaxDescTableMap.php
+++ b/core/lib/Thelia/Model/map/TaxDescTableMap.php
@@ -43,7 +43,7 @@ class TaxDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('TAX_ID', 'TaxId', 'INTEGER', true, null, null);
+ $this->addForeignKey('TAX_ID', 'TaxId', 'INTEGER', 'tax', 'ID', true, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -57,7 +57,7 @@ class TaxDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::ONE_TO_ONE, array('tax_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // TaxDescTableMap
diff --git a/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php b/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php
index edb329abb..e079f9f71 100644
--- a/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php
+++ b/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php
@@ -43,9 +43,9 @@ class TaxRuleCountryTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', false, null, null);
- $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', false, null, null);
- $this->addColumn('TAX_ID', 'TaxId', 'INTEGER', false, null, null);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
+ $this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', false, null, null);
+ $this->addForeignKey('TAX_ID', 'TaxId', 'INTEGER', 'tax', 'ID', false, null, null);
$this->addColumn('NONE', 'None', 'TINYINT', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
@@ -57,9 +57,9 @@ class TaxRuleCountryTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::ONE_TO_ONE, array('country_id' => 'id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::ONE_TO_ONE, array('tax_id' => 'id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::ONE_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $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);
} // buildRelations()
} // TaxRuleCountryTableMap
diff --git a/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php b/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php
index 230f69111..c47c81112 100644
--- a/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php
+++ b/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php
@@ -43,7 +43,7 @@ class TaxRuleDescTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', false, null, null);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
$this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
@@ -57,7 +57,7 @@ class TaxRuleDescTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::ONE_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // TaxRuleDescTableMap
diff --git a/core/lib/Thelia/Model/map/TaxRuleTableMap.php b/core/lib/Thelia/Model/map/TaxRuleTableMap.php
index a2f2eff17..def7cbb5d 100644
--- a/core/lib/Thelia/Model/map/TaxRuleTableMap.php
+++ b/core/lib/Thelia/Model/map/TaxRuleTableMap.php
@@ -42,9 +42,7 @@ class TaxRuleTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'TAX_RULE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule_country', 'TAX_RULE_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule_desc', 'TAX_RULE_ID', true, null, null);
+ $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);
@@ -56,9 +54,9 @@ class TaxRuleTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('id' => 'tax_rule_id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::MANY_TO_ONE, array('id' => 'tax_rule_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('TaxRuleDesc', 'Thelia\\Model\\TaxRuleDesc', RelationMap::MANY_TO_ONE, array('id' => 'tax_rule_id', ), 'CASCADE', 'RESTRICT');
+ $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');
} // buildRelations()
} // TaxRuleTableMap
diff --git a/core/lib/Thelia/Model/map/TaxTableMap.php b/core/lib/Thelia/Model/map/TaxTableMap.php
index a5bf65fac..15c0c6a29 100644
--- a/core/lib/Thelia/Model/map/TaxTableMap.php
+++ b/core/lib/Thelia/Model/map/TaxTableMap.php
@@ -42,8 +42,7 @@ class TaxTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(true);
// columns
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_desc', 'TAX_ID', true, null, null);
- $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule_country', 'TAX_ID', true, null, null);
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('RATE', 'Rate', 'FLOAT', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
@@ -55,8 +54,8 @@ class TaxTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('TaxDesc', 'Thelia\\Model\\TaxDesc', RelationMap::MANY_TO_ONE, array('id' => 'tax_id', ), 'CASCADE', 'RESTRICT');
- $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::MANY_TO_ONE, array('id' => 'tax_id', ), 'SET NULL', 'RESTRICT');
+ $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');
} // buildRelations()
} // TaxTableMap
diff --git a/core/lib/Thelia/Model/om/BaseAccessory.php b/core/lib/Thelia/Model/om/BaseAccessory.php
index 2181d8f9f..091f34f0a 100644
--- a/core/lib/Thelia/Model/om/BaseAccessory.php
+++ b/core/lib/Thelia/Model/om/BaseAccessory.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Accessory;
use Thelia\Model\AccessoryPeer;
@@ -86,14 +84,14 @@ abstract class BaseAccessory extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Product one-to-one related Product object
+ * @var Product
*/
- protected $singleProduct;
+ protected $aProductRelatedByProductId;
/**
- * @var Product one-to-one related Product object
+ * @var Product
*/
- protected $singleProduct;
+ protected $aProductRelatedByAccessory;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -109,18 +107,6 @@ abstract class BaseAccessory extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -273,6 +259,10 @@ abstract class BaseAccessory extends BaseObject implements Persistent
$this->modifiedColumns[] = AccessoryPeer::PRODUCT_ID;
}
+ if ($this->aProductRelatedByProductId !== null && $this->aProductRelatedByProductId->getId() !== $v) {
+ $this->aProductRelatedByProductId = null;
+ }
+
return $this;
} // setProductId()
@@ -294,6 +284,10 @@ abstract class BaseAccessory extends BaseObject implements Persistent
$this->modifiedColumns[] = AccessoryPeer::ACCESSORY;
}
+ if ($this->aProductRelatedByAccessory !== null && $this->aProductRelatedByAccessory->getId() !== $v) {
+ $this->aProductRelatedByAccessory = null;
+ }
+
return $this;
} // setAccessory()
@@ -434,6 +428,12 @@ abstract class BaseAccessory extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aProductRelatedByProductId !== null && $this->product_id !== $this->aProductRelatedByProductId->getId()) {
+ $this->aProductRelatedByProductId = null;
+ }
+ if ($this->aProductRelatedByAccessory !== null && $this->accessory !== $this->aProductRelatedByAccessory->getId()) {
+ $this->aProductRelatedByAccessory = null;
+ }
} // ensureConsistency
/**
@@ -473,10 +473,8 @@ abstract class BaseAccessory extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleProduct = null;
-
- $this->singleProduct = null;
-
+ $this->aProductRelatedByProductId = null;
+ $this->aProductRelatedByAccessory = null;
} // if (deep)
}
@@ -590,6 +588,25 @@ abstract class BaseAccessory extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProductRelatedByProductId !== null) {
+ if ($this->aProductRelatedByProductId->isModified() || $this->aProductRelatedByProductId->isNew()) {
+ $affectedRows += $this->aProductRelatedByProductId->save($con);
+ }
+ $this->setProductRelatedByProductId($this->aProductRelatedByProductId);
+ }
+
+ if ($this->aProductRelatedByAccessory !== null) {
+ if ($this->aProductRelatedByAccessory->isModified() || $this->aProductRelatedByAccessory->isNew()) {
+ $affectedRows += $this->aProductRelatedByAccessory->save($con);
+ }
+ $this->setProductRelatedByAccessory($this->aProductRelatedByAccessory);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -601,36 +618,6 @@ abstract class BaseAccessory extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
- }
- }
-
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -787,23 +774,29 @@ abstract class BaseAccessory extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProductRelatedByProductId !== null) {
+ if (!$this->aProductRelatedByProductId->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProductRelatedByProductId->getValidationFailures());
+ }
+ }
+
+ if ($this->aProductRelatedByAccessory !== null) {
+ if (!$this->aProductRelatedByAccessory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProductRelatedByAccessory->getValidationFailures());
+ }
+ }
+
+
if (($retval = AccessoryPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -894,11 +887,11 @@ abstract class BaseAccessory extends BaseObject implements Persistent
$keys[5] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProductRelatedByProductId) {
+ $result['ProductRelatedByProductId'] = $this->aProductRelatedByProductId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProductRelatedByAccessory) {
+ $result['ProductRelatedByAccessory'] = $this->aProductRelatedByAccessory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1075,16 +1068,6 @@ abstract class BaseAccessory extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1135,91 +1118,108 @@ abstract class BaseAccessory extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Product object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Product
- * @throws PropelException
- */
- public function getProduct(PropelPDO $con = null)
- {
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleProduct;
- }
-
- /**
- * Sets a single Product object as related to this object by a one-to-one relationship.
- *
- * @param Product $v Product
+ * @param Product $v
* @return Accessory The current object (for fluent API support)
* @throws PropelException
*/
- public function setProduct(Product $v = null)
+ public function setProductRelatedByProductId(Product $v = null)
{
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getAccessory() === null) {
- $v->setAccessory($this);
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
}
+ $this->aProductRelatedByProductId = $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 ($v !== null) {
+ $v->addAccessoryRelatedByProductId($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
+ * Get the associated Product object
*
- * @param PropelPDO $con optional connection object
- * @return Product
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
* @throws PropelException
*/
- public function getProduct(PropelPDO $con = null)
+ public function getProductRelatedByProductId(PropelPDO $con = null)
{
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aProductRelatedByProductId === null && ($this->product_id !== null)) {
+ $this->aProductRelatedByProductId = 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->aProductRelatedByProductId->addAccessorysRelatedByProductId($this);
+ */
}
- return $this->singleProduct;
+ return $this->aProductRelatedByProductId;
}
/**
- * Sets a single Product object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Product object.
*
- * @param Product $v Product
+ * @param Product $v
* @return Accessory The current object (for fluent API support)
* @throws PropelException
*/
- public function setProduct(Product $v = null)
+ public function setProductRelatedByAccessory(Product $v = null)
{
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getAccessory() === null) {
- $v->setAccessory($this);
+ if ($v === null) {
+ $this->setAccessory(NULL);
+ } else {
+ $this->setAccessory($v->getId());
}
+ $this->aProductRelatedByAccessory = $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 ($v !== null) {
+ $v->addAccessoryRelatedByAccessory($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Product object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
+ * @throws PropelException
+ */
+ public function getProductRelatedByAccessory(PropelPDO $con = null)
+ {
+ if ($this->aProductRelatedByAccessory === null && ($this->accessory !== null)) {
+ $this->aProductRelatedByAccessory = ProductQuery::create()->findPk($this->accessory, $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->aProductRelatedByAccessory->addAccessorysRelatedByAccessory($this);
+ */
+ }
+
+ return $this->aProductRelatedByAccessory;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1251,22 +1251,10 @@ abstract class BaseAccessory extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
- }
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
+ $this->aProductRelatedByProductId = null;
+ $this->aProductRelatedByAccessory = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAccessoryPeer.php b/core/lib/Thelia/Model/om/BaseAccessoryPeer.php
index 117860a06..f9d5ee6e9 100644
--- a/core/lib/Thelia/Model/om/BaseAccessoryPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAccessoryPeer.php
@@ -25,7 +25,7 @@ abstract class BaseAccessoryPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'accessory';
@@ -388,12 +388,6 @@ abstract class BaseAccessoryPeer
*/
public static function clearRelatedInstancePool()
{
- // 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 ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
}
/**
@@ -490,6 +484,585 @@ abstract class BaseAccessoryPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related ProductRelatedByProductId table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinProductRelatedByProductId(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AccessoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related ProductRelatedByAccessory table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinProductRelatedByAccessory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AccessoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Accessory 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
+ * @return array Array of Accessory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinProductRelatedByProductId(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+ }
+
+ AccessoryPeer::addSelectColumns($criteria);
+ $startcol = AccessoryPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AccessoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AccessoryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Accessory) to $obj2 (Product)
+ $obj2->addAccessoryRelatedByProductId($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Accessory 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
+ * @return array Array of Accessory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinProductRelatedByAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+ }
+
+ AccessoryPeer::addSelectColumns($criteria);
+ $startcol = AccessoryPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AccessoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AccessoryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Accessory) to $obj2 (Product)
+ $obj2->addAccessoryRelatedByAccessory($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AccessoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of Accessory objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Accessory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+ }
+
+ AccessoryPeer::addSelectColumns($criteria);
+ $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AccessoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AccessoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (Accessory) to the collection in $obj2 (Product)
+ $obj2->addAccessoryRelatedByProductId($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Product rows
+
+ $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ProductPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ProductPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (Accessory) to the collection in $obj3 (Product)
+ $obj3->addAccessoryRelatedByAccessory($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related ProductRelatedByProductId table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptProductRelatedByProductId(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AccessoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related ProductRelatedByAccessory table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptProductRelatedByAccessory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AccessoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Accessory objects pre-filled with all related objects except ProductRelatedByProductId.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Accessory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptProductRelatedByProductId(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+ }
+
+ AccessoryPeer::addSelectColumns($criteria);
+ $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS;
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AccessoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AccessoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Accessory objects pre-filled with all related objects except ProductRelatedByAccessory.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Accessory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptProductRelatedByAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+ }
+
+ AccessoryPeer::addSelectColumns($criteria);
+ $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS;
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AccessoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AccessoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -619,7 +1192,6 @@ abstract class BaseAccessoryPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += AccessoryPeer::doOnDeleteCascade(new Criteria(AccessoryPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(AccessoryPeer::TABLE_NAME, $con, AccessoryPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -653,14 +1225,24 @@ abstract class BaseAccessoryPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ AccessoryPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Accessory) { // it's a model object
+ // invalidate the cache for this single object
+ AccessoryPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
$criteria->add(AccessoryPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AccessoryPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -673,23 +1255,6 @@ abstract class BaseAccessoryPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += AccessoryPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- AccessoryPeer::clearInstancePool();
- } elseif ($values instanceof Accessory) { // it's a model object
- AccessoryPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- AccessoryPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
AccessoryPeer::clearRelatedInstancePool();
$con->commit();
@@ -701,45 +1266,6 @@ abstract class BaseAccessoryPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = AccessoryPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getAccessory());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given Accessory object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php
index ac791139d..b1de88d0b 100644
--- a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php
@@ -40,13 +40,13 @@ use Thelia\Model\Product;
* @method AccessoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method AccessoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method AccessoryQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
- * @method AccessoryQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
- * @method AccessoryQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
+ * @method AccessoryQuery leftJoinProductRelatedByProductId($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductRelatedByProductId relation
+ * @method AccessoryQuery rightJoinProductRelatedByProductId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductRelatedByProductId relation
+ * @method AccessoryQuery innerJoinProductRelatedByProductId($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductRelatedByProductId relation
*
- * @method AccessoryQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
- * @method AccessoryQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
- * @method AccessoryQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
+ * @method AccessoryQuery leftJoinProductRelatedByAccessory($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductRelatedByAccessory relation
+ * @method AccessoryQuery rightJoinProductRelatedByAccessory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductRelatedByAccessory relation
+ * @method AccessoryQuery innerJoinProductRelatedByAccessory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductRelatedByAccessory relation
*
* @method Accessory findOne(PropelPDO $con = null) Return the first Accessory matching the query
* @method Accessory findOneOrCreate(PropelPDO $con = null) Return the first Accessory matching the query, or a new Accessory object populated from the query conditions when no match is found
@@ -76,7 +76,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Accessory', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Accessory', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -279,6 +279,8 @@ abstract class BaseAccessoryQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProductRelatedByProductId()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -320,6 +322,8 @@ abstract class BaseAccessoryQuery extends ModelCriteria
* $query->filterByAccessory(array('min' => 12)); // WHERE accessory > 12
*
*
+ * @see filterByProductRelatedByAccessory()
+ *
* @param mixed $accessory The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -481,39 +485,41 @@ abstract class BaseAccessoryQuery extends ModelCriteria
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product the related object 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 AccessoryQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByProduct($product, $comparison = null)
+ public function filterByProductRelatedByProductId($product, $comparison = null)
{
if ($product instanceof Product) {
return $this
->addUsingAlias(AccessoryPeer::PRODUCT_ID, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AccessoryPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
- throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
+ throw new PropelException('filterByProductRelatedByProductId() only accepts arguments of type Product or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the Product relation
+ * Adds a JOIN clause to the query using the ProductRelatedByProductId relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return AccessoryQuery The current query, for fluid interface
*/
- public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinProductRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Product');
+ $relationMap = $tableMap->getRelation('ProductRelatedByProductId');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -528,14 +534,14 @@ abstract class BaseAccessoryQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'Product');
+ $this->addJoinObject($join, 'ProductRelatedByProductId');
}
return $this;
}
/**
- * Use the Product relation Product object
+ * Use the ProductRelatedByProductId relation Product object
*
* @see useQuery()
*
@@ -545,49 +551,51 @@ abstract class BaseAccessoryQuery extends ModelCriteria
*
* @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
*/
- public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useProductRelatedByProductIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
- ->joinProduct($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ ->joinProductRelatedByProductId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductRelatedByProductId', '\Thelia\Model\ProductQuery');
}
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product the related object 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 AccessoryQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByProduct($product, $comparison = null)
+ public function filterByProductRelatedByAccessory($product, $comparison = null)
{
if ($product instanceof Product) {
return $this
->addUsingAlias(AccessoryPeer::ACCESSORY, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AccessoryPeer::ACCESSORY, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
- throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
+ throw new PropelException('filterByProductRelatedByAccessory() only accepts arguments of type Product or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the Product relation
+ * Adds a JOIN clause to the query using the ProductRelatedByAccessory relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return AccessoryQuery The current query, for fluid interface
*/
- public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinProductRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Product');
+ $relationMap = $tableMap->getRelation('ProductRelatedByAccessory');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -602,14 +610,14 @@ abstract class BaseAccessoryQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'Product');
+ $this->addJoinObject($join, 'ProductRelatedByAccessory');
}
return $this;
}
/**
- * Use the Product relation Product object
+ * Use the ProductRelatedByAccessory relation Product object
*
* @see useQuery()
*
@@ -619,11 +627,11 @@ abstract class BaseAccessoryQuery extends ModelCriteria
*
* @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
*/
- public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useProductRelatedByAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
- ->joinProduct($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ ->joinProductRelatedByAccessory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductRelatedByAccessory', '\Thelia\Model\ProductQuery');
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAddress.php b/core/lib/Thelia/Model/om/BaseAddress.php
index 06863f288..75feacbd3 100644
--- a/core/lib/Thelia/Model/om/BaseAddress.php
+++ b/core/lib/Thelia/Model/om/BaseAddress.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Address;
use Thelia\Model\AddressPeer;
@@ -148,14 +146,14 @@ abstract class BaseAddress extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Customer one-to-one related Customer object
+ * @var Customer
*/
- protected $singleCustomer;
+ protected $aCustomer;
/**
- * @var CustomerTitle one-to-one related CustomerTitle object
+ * @var CustomerTitle
*/
- protected $singleCustomerTitle;
+ protected $aCustomerTitle;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -171,18 +169,6 @@ abstract class BaseAddress extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $customersScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $customerTitlesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -456,6 +442,10 @@ abstract class BaseAddress extends BaseObject implements Persistent
$this->modifiedColumns[] = AddressPeer::CUSTOMER_ID;
}
+ if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
+ $this->aCustomer = null;
+ }
+
return $this;
} // setCustomerId()
@@ -477,6 +467,10 @@ abstract class BaseAddress extends BaseObject implements Persistent
$this->modifiedColumns[] = AddressPeer::CUSTOMER_TITLE_ID;
}
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
return $this;
} // setCustomerTitleId()
@@ -816,6 +810,12 @@ abstract class BaseAddress extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
+ $this->aCustomer = null;
+ }
+ if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
+ }
} // ensureConsistency
/**
@@ -855,10 +855,8 @@ abstract class BaseAddress extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCustomer = null;
-
- $this->singleCustomerTitle = null;
-
+ $this->aCustomer = null;
+ $this->aCustomerTitle = null;
} // if (deep)
}
@@ -972,6 +970,25 @@ abstract class BaseAddress extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCustomer !== null) {
+ if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) {
+ $affectedRows += $this->aCustomer->save($con);
+ }
+ $this->setCustomer($this->aCustomer);
+ }
+
+ if ($this->aCustomerTitle !== null) {
+ if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
+ $affectedRows += $this->aCustomerTitle->save($con);
+ }
+ $this->setCustomerTitle($this->aCustomerTitle);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -983,36 +1000,6 @@ abstract class BaseAddress extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->customersScheduledForDeletion !== null) {
- if (!$this->customersScheduledForDeletion->isEmpty()) {
- CustomerQuery::create()
- ->filterByPrimaryKeys($this->customersScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->customersScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCustomer !== null) {
- if (!$this->singleCustomer->isDeleted()) {
- $affectedRows += $this->singleCustomer->save($con);
- }
- }
-
- if ($this->customerTitlesScheduledForDeletion !== null) {
- if (!$this->customerTitlesScheduledForDeletion->isEmpty()) {
- CustomerTitleQuery::create()
- ->filterByPrimaryKeys($this->customerTitlesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->customerTitlesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCustomerTitle !== null) {
- if (!$this->singleCustomerTitle->isDeleted()) {
- $affectedRows += $this->singleCustomerTitle->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -1240,23 +1227,29 @@ abstract class BaseAddress extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCustomer !== null) {
+ if (!$this->aCustomer->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCustomer->getValidationFailures());
+ }
+ }
+
+ if ($this->aCustomerTitle !== null) {
+ if (!$this->aCustomerTitle->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCustomerTitle->getValidationFailures());
+ }
+ }
+
+
if (($retval = AddressPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCustomer !== null) {
- if (!$this->singleCustomer->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCustomer->getValidationFailures());
- }
- }
-
- if ($this->singleCustomerTitle !== null) {
- if (!$this->singleCustomerTitle->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCustomerTitle->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -1387,11 +1380,11 @@ abstract class BaseAddress extends BaseObject implements Persistent
$keys[15] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCustomer) {
- $result['Customer'] = $this->singleCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCustomer) {
+ $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleCustomerTitle) {
- $result['CustomerTitle'] = $this->singleCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1628,16 +1621,6 @@ abstract class BaseAddress extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCustomer();
- if ($relObj) {
- $copyObj->setCustomer($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getCustomerTitle();
- if ($relObj) {
- $copyObj->setCustomerTitle($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1688,91 +1671,108 @@ abstract class BaseAddress extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Customer object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Customer object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Customer
- * @throws PropelException
- */
- public function getCustomer(PropelPDO $con = null)
- {
-
- if ($this->singleCustomer === null && !$this->isNew()) {
- $this->singleCustomer = CustomerQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCustomer;
- }
-
- /**
- * Sets a single Customer object as related to this object by a one-to-one relationship.
- *
- * @param Customer $v Customer
+ * @param Customer $v
* @return Address The current object (for fluent API support)
* @throws PropelException
*/
public function setCustomer(Customer $v = null)
{
- $this->singleCustomer = $v;
-
- // Make sure that that the passed-in Customer isn't already associated with this object
- if ($v !== null && $v->getAddress() === null) {
- $v->setAddress($this);
+ if ($v === null) {
+ $this->setCustomerId(NULL);
+ } else {
+ $this->setCustomerId($v->getId());
}
+ $this->aCustomer = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Customer object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAddress($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single CustomerTitle object, which is related to this object by a one-to-one relationship.
+ * Get the associated Customer object
*
- * @param PropelPDO $con optional connection object
- * @return CustomerTitle
+ * @param PropelPDO $con Optional Connection object.
+ * @return Customer The associated Customer object.
* @throws PropelException
*/
- public function getCustomerTitle(PropelPDO $con = null)
+ public function getCustomer(PropelPDO $con = null)
{
-
- if ($this->singleCustomerTitle === null && !$this->isNew()) {
- $this->singleCustomerTitle = CustomerTitleQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aCustomer === null && ($this->customer_id !== null)) {
+ $this->aCustomer = CustomerQuery::create()->findPk($this->customer_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->aCustomer->addAddresss($this);
+ */
}
- return $this->singleCustomerTitle;
+ return $this->aCustomer;
}
/**
- * Sets a single CustomerTitle object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a CustomerTitle object.
*
- * @param CustomerTitle $v CustomerTitle
+ * @param CustomerTitle $v
* @return Address The current object (for fluent API support)
* @throws PropelException
*/
public function setCustomerTitle(CustomerTitle $v = null)
{
- $this->singleCustomerTitle = $v;
-
- // Make sure that that the passed-in CustomerTitle isn't already associated with this object
- if ($v !== null && $v->getAddress() === null) {
- $v->setAddress($this);
+ if ($v === null) {
+ $this->setCustomerTitleId(NULL);
+ } else {
+ $this->setCustomerTitleId($v->getId());
}
+ $this->aCustomerTitle = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the CustomerTitle object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAddress($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated CustomerTitle object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return CustomerTitle The associated CustomerTitle object.
+ * @throws PropelException
+ */
+ public function getCustomerTitle(PropelPDO $con = null)
+ {
+ if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) {
+ $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_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->aCustomerTitle->addAddresss($this);
+ */
+ }
+
+ return $this->aCustomerTitle;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1814,22 +1814,10 @@ abstract class BaseAddress extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCustomer) {
- $this->singleCustomer->clearAllReferences($deep);
- }
- if ($this->singleCustomerTitle) {
- $this->singleCustomerTitle->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCustomer instanceof PropelCollection) {
- $this->singleCustomer->clearIterator();
- }
- $this->singleCustomer = null;
- if ($this->singleCustomerTitle instanceof PropelCollection) {
- $this->singleCustomerTitle->clearIterator();
- }
- $this->singleCustomerTitle = null;
+ $this->aCustomer = null;
+ $this->aCustomerTitle = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAddressPeer.php b/core/lib/Thelia/Model/om/BaseAddressPeer.php
index 1931d252d..7ffed74ba 100644
--- a/core/lib/Thelia/Model/om/BaseAddressPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAddressPeer.php
@@ -12,6 +12,7 @@ use \PropelPDO;
use Thelia\Model\Address;
use Thelia\Model\AddressPeer;
use Thelia\Model\CustomerPeer;
+use Thelia\Model\CustomerTitlePeer;
use Thelia\Model\map\AddressTableMap;
/**
@@ -25,7 +26,7 @@ abstract class BaseAddressPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'address';
@@ -438,9 +439,6 @@ abstract class BaseAddressPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CustomerPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CustomerPeer::clearInstancePool();
}
/**
@@ -537,6 +535,637 @@ abstract class BaseAddressPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Customer table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCustomer(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AddressPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related CustomerTitle table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCustomerTitle(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AddressPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Address objects pre-filled with their Customer objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Address objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+ }
+
+ AddressPeer::addSelectColumns($criteria);
+ $startcol = AddressPeer::NUM_HYDRATE_COLUMNS;
+ CustomerPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AddressPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AddressPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CustomerPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CustomerPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CustomerPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Address) to $obj2 (Customer)
+ $obj2->addAddress($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Address objects pre-filled with their CustomerTitle objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Address objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+ }
+
+ AddressPeer::addSelectColumns($criteria);
+ $startcol = AddressPeer::NUM_HYDRATE_COLUMNS;
+ CustomerTitlePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AddressPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AddressPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CustomerTitlePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CustomerTitlePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Address) to $obj2 (CustomerTitle)
+ $obj2->addAddress($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AddressPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of Address objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Address objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+ }
+
+ AddressPeer::addSelectColumns($criteria);
+ $startcol2 = AddressPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerTitlePeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AddressPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AddressPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Customer rows
+
+ $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CustomerPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CustomerPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CustomerPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (Address) to the collection in $obj2 (Customer)
+ $obj2->addAddress($obj1);
+ } // if joined row not null
+
+ // Add objects for joined CustomerTitle rows
+
+ $key3 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CustomerTitlePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CustomerTitlePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CustomerTitlePeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (Address) to the collection in $obj3 (CustomerTitle)
+ $obj3->addAddress($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Customer table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCustomer(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AddressPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related CustomerTitle table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCustomerTitle(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AddressPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Address objects pre-filled with all related objects except Customer.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Address objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+ }
+
+ AddressPeer::addSelectColumns($criteria);
+ $startcol2 = AddressPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerTitlePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AddressPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AddressPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined CustomerTitle rows
+
+ $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CustomerTitlePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CustomerTitlePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Address) to the collection in $obj2 (CustomerTitle)
+ $obj2->addAddress($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Address objects pre-filled with all related objects except CustomerTitle.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Address objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+ }
+
+ AddressPeer::addSelectColumns($criteria);
+ $startcol2 = AddressPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AddressPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AddressPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Customer rows
+
+ $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CustomerPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CustomerPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CustomerPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Address) to the collection in $obj2 (Customer)
+ $obj2->addAddress($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -670,7 +1299,6 @@ abstract class BaseAddressPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += AddressPeer::doOnDeleteCascade(new Criteria(AddressPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(AddressPeer::TABLE_NAME, $con, AddressPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -704,14 +1332,24 @@ abstract class BaseAddressPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ AddressPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Address) { // it's a model object
+ // invalidate the cache for this single object
+ AddressPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AddressPeer::DATABASE_NAME);
$criteria->add(AddressPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AddressPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -724,23 +1362,6 @@ abstract class BaseAddressPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += AddressPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- AddressPeer::clearInstancePool();
- } elseif ($values instanceof Address) { // it's a model object
- AddressPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- AddressPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
AddressPeer::clearRelatedInstancePool();
$con->commit();
@@ -752,39 +1373,6 @@ abstract class BaseAddressPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = AddressPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Customer objects
- $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
-
- $criteria->add(CustomerPeer::ID, $obj->getCustomerId());
- $affectedRows += CustomerPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given Address object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseAddressQuery.php b/core/lib/Thelia/Model/om/BaseAddressQuery.php
index 37b76f4bf..88ca88e7f 100644
--- a/core/lib/Thelia/Model/om/BaseAddressQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAddressQuery.php
@@ -117,7 +117,7 @@ abstract class BaseAddressQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Address', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Address', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -349,6 +349,8 @@ abstract class BaseAddressQuery extends ModelCriteria
* $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
*
*
+ * @see filterByCustomer()
+ *
* @param mixed $customerId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -390,6 +392,8 @@ abstract class BaseAddressQuery extends ModelCriteria
* $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
*
*
+ * @see filterByCustomerTitle()
+ *
* @param mixed $customerTitleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -812,7 +816,7 @@ abstract class BaseAddressQuery extends ModelCriteria
/**
* Filter the query by a related Customer object
*
- * @param Customer|PropelObjectCollection $customer the related object to use as filter
+ * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AddressQuery The current query, for fluid interface
@@ -824,10 +828,12 @@ abstract class BaseAddressQuery extends ModelCriteria
return $this
->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->getId(), $comparison);
} elseif ($customer instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCustomerQuery()
- ->filterByPrimaryKeys($customer->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
}
@@ -886,7 +892,7 @@ abstract class BaseAddressQuery extends ModelCriteria
/**
* Filter the query by a related CustomerTitle object
*
- * @param CustomerTitle|PropelObjectCollection $customerTitle the related object to use as filter
+ * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AddressQuery The current query, for fluid interface
@@ -898,10 +904,12 @@ abstract class BaseAddressQuery extends ModelCriteria
return $this
->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
} elseif ($customerTitle instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCustomerTitleQuery()
- ->filterByPrimaryKeys($customerTitle->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection');
}
@@ -915,7 +923,7 @@ abstract class BaseAddressQuery extends ModelCriteria
*
* @return AddressQuery The current query, for fluid interface
*/
- public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CustomerTitle');
@@ -950,7 +958,7 @@ abstract class BaseAddressQuery extends ModelCriteria
*
* @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
*/
- public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinCustomerTitle($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseAdmin.php b/core/lib/Thelia/Model/om/BaseAdmin.php
index 239df297e..4937b7d42 100644
--- a/core/lib/Thelia/Model/om/BaseAdmin.php
+++ b/core/lib/Thelia/Model/om/BaseAdmin.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Admin;
use Thelia\Model\AdminGroup;
@@ -102,9 +104,10 @@ abstract class BaseAdmin extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var AdminGroup
+ * @var PropelObjectCollection|AdminGroup[] Collection to store aggregation of AdminGroup objects.
*/
- protected $aAdminGroup;
+ protected $collAdminGroups;
+ protected $collAdminGroupsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -120,6 +123,12 @@ abstract class BaseAdmin extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $adminGroupsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -281,10 +290,6 @@ abstract class BaseAdmin extends BaseObject implements Persistent
$this->modifiedColumns[] = AdminPeer::ID;
}
- if ($this->aAdminGroup !== null && $this->aAdminGroup->getAdminId() !== $v) {
- $this->aAdminGroup = null;
- }
-
return $this;
} // setId()
@@ -533,9 +538,6 @@ abstract class BaseAdmin extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAdminGroup !== null && $this->id !== $this->aAdminGroup->getAdminId()) {
- $this->aAdminGroup = null;
- }
} // ensureConsistency
/**
@@ -575,7 +577,8 @@ abstract class BaseAdmin extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAdminGroup = null;
+ $this->collAdminGroups = null;
+
} // if (deep)
}
@@ -689,18 +692,6 @@ abstract class BaseAdmin extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAdminGroup !== null) {
- if ($this->aAdminGroup->isModified() || $this->aAdminGroup->isNew()) {
- $affectedRows += $this->aAdminGroup->save($con);
- }
- $this->setAdminGroup($this->aAdminGroup);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -712,6 +703,24 @@ abstract class BaseAdmin extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->adminGroupsScheduledForDeletion !== null) {
+ if (!$this->adminGroupsScheduledForDeletion->isEmpty()) {
+ foreach ($this->adminGroupsScheduledForDeletion as $adminGroup) {
+ // need to save related object because we set the relation to null
+ $adminGroup->save($con);
+ }
+ $this->adminGroupsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAdminGroups !== null) {
+ foreach ($this->collAdminGroups as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -897,23 +906,19 @@ abstract class BaseAdmin extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAdminGroup !== null) {
- if (!$this->aAdminGroup->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAdminGroup->getValidationFailures());
- }
- }
-
-
if (($retval = AdminPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collAdminGroups !== null) {
+ foreach ($this->collAdminGroups as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1016,8 +1021,8 @@ abstract class BaseAdmin extends BaseObject implements Persistent
$keys[8] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAdminGroup) {
- $result['AdminGroup'] = $this->aAdminGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAdminGroups) {
+ $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1212,9 +1217,10 @@ abstract class BaseAdmin extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAdminGroup();
- if ($relObj) {
- $copyObj->setAdminGroup($relObj->copy($deepCopy));
+ 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));
+ }
}
//unflag object copy
@@ -1267,51 +1273,252 @@ abstract class BaseAdmin extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a AdminGroup object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param AdminGroup $v
- * @return Admin The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AdminGroup' == $relationName) {
+ $this->initAdminGroups();
+ }
+ }
+
+ /**
+ * Clears out the collAdminGroups 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 addAdminGroups()
+ */
+ public function clearAdminGroups()
+ {
+ $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized
+ $this->collAdminGroupsPartial = null;
+ }
+
+ /**
+ * reset is the collAdminGroups collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAdminGroups($v = true)
+ {
+ $this->collAdminGroupsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAdminGroups collection.
+ *
+ * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups());
+ * 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 initAdminGroups($overrideExisting = true)
+ {
+ if (null !== $this->collAdminGroups && !$overrideExisting) {
+ return;
+ }
+ $this->collAdminGroups = new PropelObjectCollection();
+ $this->collAdminGroups->setModel('AdminGroup');
+ }
+
+ /**
+ * Gets an array of AdminGroup 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 Admin 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|AdminGroup[] List of AdminGroup objects
* @throws PropelException
*/
- public function setAdminGroup(AdminGroup $v = null)
+ public function getAdminGroups($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collAdminGroupsPartial && !$this->isNew();
+ if (null === $this->collAdminGroups || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAdminGroups) {
+ // return empty collection
+ $this->initAdminGroups();
+ } else {
+ $collAdminGroups = AdminGroupQuery::create(null, $criteria)
+ ->filterByAdmin($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) {
+ $this->initAdminGroups(false);
+
+ foreach($collAdminGroups as $obj) {
+ if (false == $this->collAdminGroups->contains($obj)) {
+ $this->collAdminGroups->append($obj);
+ }
+ }
+
+ $this->collAdminGroupsPartial = true;
+ }
+
+ return $collAdminGroups;
+ }
+
+ if($partial && $this->collAdminGroups) {
+ foreach($this->collAdminGroups as $obj) {
+ if($obj->isNew()) {
+ $collAdminGroups[] = $obj;
+ }
+ }
+ }
+
+ $this->collAdminGroups = $collAdminGroups;
+ $this->collAdminGroupsPartial = false;
+ }
+ }
+
+ return $this->collAdminGroups;
+ }
+
+ /**
+ * Sets a collection of AdminGroup 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 $adminGroups A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null)
+ {
+ $this->adminGroupsScheduledForDeletion = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups);
+
+ foreach ($this->adminGroupsScheduledForDeletion as $adminGroupRemoved) {
+ $adminGroupRemoved->setAdmin(null);
+ }
+
+ $this->collAdminGroups = null;
+ foreach ($adminGroups as $adminGroup) {
+ $this->addAdminGroup($adminGroup);
+ }
+
+ $this->collAdminGroups = $adminGroups;
+ $this->collAdminGroupsPartial = false;
+ }
+
+ /**
+ * Returns the number of related AdminGroup objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AdminGroup objects.
+ * @throws PropelException
+ */
+ public function countAdminGroups(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAdminGroupsPartial && !$this->isNew();
+ if (null === $this->collAdminGroups || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAdminGroups) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAdminGroups());
+ }
+ $query = AdminGroupQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAdmin($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getAdminId());
+ return count($this->collAdminGroups);
}
+ }
- $this->aAdminGroup = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setAdmin($this);
+ /**
+ * Method called to associate a AdminGroup object to this object
+ * through the AdminGroup foreign key attribute.
+ *
+ * @param AdminGroup $l AdminGroup
+ * @return Admin The current object (for fluent API support)
+ */
+ public function addAdminGroup(AdminGroup $l)
+ {
+ if ($this->collAdminGroups === null) {
+ $this->initAdminGroups();
+ $this->collAdminGroupsPartial = true;
+ }
+ if (!$this->collAdminGroups->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAdminGroup($l);
}
-
return $this;
}
+ /**
+ * @param AdminGroup $adminGroup The adminGroup object to add.
+ */
+ protected function doAddAdminGroup($adminGroup)
+ {
+ $this->collAdminGroups[]= $adminGroup;
+ $adminGroup->setAdmin($this);
+ }
/**
- * Get the associated AdminGroup object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AdminGroup The associated AdminGroup object.
- * @throws PropelException
+ * @param AdminGroup $adminGroup The adminGroup object to remove.
*/
- public function getAdminGroup(PropelPDO $con = null)
+ public function removeAdminGroup($adminGroup)
{
- if ($this->aAdminGroup === null && ($this->id !== null)) {
- $this->aAdminGroup = AdminGroupQuery::create()
- ->filterByAdmin($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAdminGroup->setAdmin($this);
+ if ($this->getAdminGroups()->contains($adminGroup)) {
+ $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup));
+ if (null === $this->adminGroupsScheduledForDeletion) {
+ $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups;
+ $this->adminGroupsScheduledForDeletion->clear();
+ }
+ $this->adminGroupsScheduledForDeletion[]= $adminGroup;
+ $adminGroup->setAdmin(null);
}
+ }
- return $this->aAdminGroup;
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Admin is new, it will return
+ * an empty collection; or if this Admin has previously
+ * been saved, it will retrieve related AdminGroups 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 Admin.
+ *
+ * @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|AdminGroup[] List of AdminGroup objects
+ */
+ public function getAdminGroupsJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AdminGroupQuery::create(null, $criteria);
+ $query->joinWith('Group', $join_behavior);
+
+ return $this->getAdminGroups($query, $con);
}
/**
@@ -1348,9 +1555,17 @@ abstract class BaseAdmin extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collAdminGroups) {
+ foreach ($this->collAdminGroups as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aAdminGroup = null;
+ if ($this->collAdminGroups instanceof PropelCollection) {
+ $this->collAdminGroups->clearIterator();
+ }
+ $this->collAdminGroups = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAdminGroup.php b/core/lib/Thelia/Model/om/BaseAdminGroup.php
index e7cb8adee..9827859c4 100644
--- a/core/lib/Thelia/Model/om/BaseAdminGroup.php
+++ b/core/lib/Thelia/Model/om/BaseAdminGroup.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Admin;
use Thelia\Model\AdminGroup;
@@ -82,14 +80,14 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Admin one-to-one related Admin object
+ * @var Group
*/
- protected $singleAdmin;
+ protected $aGroup;
/**
- * @var Group one-to-one related Group object
+ * @var Admin
*/
- protected $singleGroup;
+ protected $aAdmin;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -105,18 +103,6 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $adminsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $groupsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -259,6 +245,10 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
$this->modifiedColumns[] = AdminGroupPeer::GROUP_ID;
}
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
return $this;
} // setGroupId()
@@ -280,6 +270,10 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
$this->modifiedColumns[] = AdminGroupPeer::ADMIN_ID;
}
+ if ($this->aAdmin !== null && $this->aAdmin->getId() !== $v) {
+ $this->aAdmin = null;
+ }
+
return $this;
} // setAdminId()
@@ -398,6 +392,12 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
+ if ($this->aAdmin !== null && $this->admin_id !== $this->aAdmin->getId()) {
+ $this->aAdmin = null;
+ }
} // ensureConsistency
/**
@@ -437,10 +437,8 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleAdmin = null;
-
- $this->singleGroup = null;
-
+ $this->aGroup = null;
+ $this->aAdmin = null;
} // if (deep)
}
@@ -554,6 +552,25 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
+ $affectedRows += $this->aGroup->save($con);
+ }
+ $this->setGroup($this->aGroup);
+ }
+
+ if ($this->aAdmin !== null) {
+ if ($this->aAdmin->isModified() || $this->aAdmin->isNew()) {
+ $affectedRows += $this->aAdmin->save($con);
+ }
+ $this->setAdmin($this->aAdmin);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -565,36 +582,6 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->adminsScheduledForDeletion !== null) {
- if (!$this->adminsScheduledForDeletion->isEmpty()) {
- AdminQuery::create()
- ->filterByPrimaryKeys($this->adminsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->adminsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleAdmin !== null) {
- if (!$this->singleAdmin->isDeleted()) {
- $affectedRows += $this->singleAdmin->save($con);
- }
- }
-
- if ($this->groupsScheduledForDeletion !== null) {
- if (!$this->groupsScheduledForDeletion->isEmpty()) {
- GroupQuery::create()
- ->filterByPrimaryKeys($this->groupsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->groupsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleGroup !== null) {
- if (!$this->singleGroup->isDeleted()) {
- $affectedRows += $this->singleGroup->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -756,23 +743,29 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if (!$this->aGroup->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures());
+ }
+ }
+
+ if ($this->aAdmin !== null) {
+ if (!$this->aAdmin->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aAdmin->getValidationFailures());
+ }
+ }
+
+
if (($retval = AdminGroupPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleAdmin !== null) {
- if (!$this->singleAdmin->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleAdmin->getValidationFailures());
- }
- }
-
- if ($this->singleGroup !== null) {
- if (!$this->singleGroup->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleGroup->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -859,11 +852,11 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleAdmin) {
- $result['Admin'] = $this->singleAdmin->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleGroup) {
- $result['Group'] = $this->singleGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aAdmin) {
+ $result['Admin'] = $this->aAdmin->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1034,16 +1027,6 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAdmin();
- if ($relObj) {
- $copyObj->setAdmin($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getGroup();
- if ($relObj) {
- $copyObj->setGroup($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1094,91 +1077,108 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Group object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Admin object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Admin
- * @throws PropelException
- */
- public function getAdmin(PropelPDO $con = null)
- {
-
- if ($this->singleAdmin === null && !$this->isNew()) {
- $this->singleAdmin = AdminQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleAdmin;
- }
-
- /**
- * Sets a single Admin object as related to this object by a one-to-one relationship.
- *
- * @param Admin $v Admin
- * @return AdminGroup The current object (for fluent API support)
- * @throws PropelException
- */
- public function setAdmin(Admin $v = null)
- {
- $this->singleAdmin = $v;
-
- // Make sure that that the passed-in Admin isn't already associated with this object
- if ($v !== null && $v->getAdminGroup() === null) {
- $v->setAdminGroup($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Group object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Group
- * @throws PropelException
- */
- public function getGroup(PropelPDO $con = null)
- {
-
- if ($this->singleGroup === null && !$this->isNew()) {
- $this->singleGroup = GroupQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleGroup;
- }
-
- /**
- * Sets a single Group object as related to this object by a one-to-one relationship.
- *
- * @param Group $v Group
+ * @param Group $v
* @return AdminGroup The current object (for fluent API support)
* @throws PropelException
*/
public function setGroup(Group $v = null)
{
- $this->singleGroup = $v;
-
- // Make sure that that the passed-in Group isn't already associated with this object
- if ($v !== null && $v->getAdminGroup() === null) {
- $v->setAdminGroup($this);
+ if ($v === null) {
+ $this->setGroupId(NULL);
+ } else {
+ $this->setGroupId($v->getId());
}
+ $this->aGroup = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Group object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAdminGroup($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Group object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Group The associated Group object.
+ * @throws PropelException
+ */
+ public function getGroup(PropelPDO $con = null)
+ {
+ if ($this->aGroup === null && ($this->group_id !== null)) {
+ $this->aGroup = GroupQuery::create()->findPk($this->group_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->aGroup->addAdminGroups($this);
+ */
+ }
+
+ return $this->aGroup;
+ }
+
+ /**
+ * Declares an association between this object and a Admin object.
+ *
+ * @param Admin $v
+ * @return AdminGroup The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAdmin(Admin $v = null)
+ {
+ if ($v === null) {
+ $this->setAdminId(NULL);
+ } else {
+ $this->setAdminId($v->getId());
+ }
+
+ $this->aAdmin = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Admin object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAdminGroup($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Admin object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Admin The associated Admin object.
+ * @throws PropelException
+ */
+ public function getAdmin(PropelPDO $con = null)
+ {
+ if ($this->aAdmin === null && ($this->admin_id !== null)) {
+ $this->aAdmin = AdminQuery::create()->findPk($this->admin_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->aAdmin->addAdminGroups($this);
+ */
+ }
+
+ return $this->aAdmin;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1209,22 +1209,10 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleAdmin) {
- $this->singleAdmin->clearAllReferences($deep);
- }
- if ($this->singleGroup) {
- $this->singleGroup->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleAdmin instanceof PropelCollection) {
- $this->singleAdmin->clearIterator();
- }
- $this->singleAdmin = null;
- if ($this->singleGroup instanceof PropelCollection) {
- $this->singleGroup->clearIterator();
- }
- $this->singleGroup = null;
+ $this->aGroup = null;
+ $this->aAdmin = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php b/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php
index f0a5ac119..6488ae3ab 100644
--- a/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php
@@ -26,7 +26,7 @@ abstract class BaseAdminGroupPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'admin_group';
@@ -384,12 +384,6 @@ abstract class BaseAdminGroupPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in AdminPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- AdminPeer::clearInstancePool();
- // Invalidate objects in GroupPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- GroupPeer::clearInstancePool();
}
/**
@@ -486,6 +480,637 @@ abstract class BaseAdminGroupPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Group table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinGroup(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AdminGroupPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Admin table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAdmin(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AdminGroupPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of AdminGroup objects pre-filled with their Group objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AdminGroup objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+ }
+
+ AdminGroupPeer::addSelectColumns($criteria);
+ $startcol = AdminGroupPeer::NUM_HYDRATE_COLUMNS;
+ GroupPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AdminGroupPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AdminGroupPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AdminGroup) to $obj2 (Group)
+ $obj2->addAdminGroup($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of AdminGroup objects pre-filled with their Admin objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AdminGroup objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAdmin(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+ }
+
+ AdminGroupPeer::addSelectColumns($criteria);
+ $startcol = AdminGroupPeer::NUM_HYDRATE_COLUMNS;
+ AdminPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AdminGroupPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AdminGroupPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = AdminPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = AdminPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AdminPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ AdminPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AdminGroup) to $obj2 (Admin)
+ $obj2->addAdminGroup($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AdminGroupPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of AdminGroup objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AdminGroup objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+ }
+
+ AdminGroupPeer::addSelectColumns($criteria);
+ $startcol2 = AdminGroupPeer::NUM_HYDRATE_COLUMNS;
+
+ GroupPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
+
+ AdminPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + AdminPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AdminGroupPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AdminGroupPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Group rows
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (AdminGroup) to the collection in $obj2 (Group)
+ $obj2->addAdminGroup($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Admin rows
+
+ $key3 = AdminPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = AdminPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = AdminPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ AdminPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (AdminGroup) to the collection in $obj3 (Admin)
+ $obj3->addAdminGroup($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Group table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptGroup(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AdminGroupPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Admin table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptAdmin(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AdminGroupPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of AdminGroup objects pre-filled with all related objects except Group.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AdminGroup objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+ }
+
+ AdminGroupPeer::addSelectColumns($criteria);
+ $startcol2 = AdminGroupPeer::NUM_HYDRATE_COLUMNS;
+
+ AdminPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AdminPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AdminGroupPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AdminGroupPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Admin rows
+
+ $key2 = AdminPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AdminPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AdminPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AdminPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (AdminGroup) to the collection in $obj2 (Admin)
+ $obj2->addAdminGroup($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of AdminGroup objects pre-filled with all related objects except Admin.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AdminGroup objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptAdmin(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+ }
+
+ AdminGroupPeer::addSelectColumns($criteria);
+ $startcol2 = AdminGroupPeer::NUM_HYDRATE_COLUMNS;
+
+ GroupPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AdminGroupPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AdminGroupPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Group rows
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (AdminGroup) to the collection in $obj2 (Group)
+ $obj2->addAdminGroup($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -619,7 +1244,6 @@ abstract class BaseAdminGroupPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += AdminGroupPeer::doOnDeleteCascade(new Criteria(AdminGroupPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(AdminGroupPeer::TABLE_NAME, $con, AdminGroupPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -653,14 +1277,24 @@ abstract class BaseAdminGroupPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ AdminGroupPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof AdminGroup) { // it's a model object
+ // invalidate the cache for this single object
+ AdminGroupPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AdminGroupPeer::DATABASE_NAME);
$criteria->add(AdminGroupPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AdminGroupPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -673,23 +1307,6 @@ abstract class BaseAdminGroupPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += AdminGroupPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- AdminGroupPeer::clearInstancePool();
- } elseif ($values instanceof AdminGroup) { // it's a model object
- AdminGroupPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- AdminGroupPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
AdminGroupPeer::clearRelatedInstancePool();
$con->commit();
@@ -701,45 +1318,6 @@ abstract class BaseAdminGroupPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = AdminGroupPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Admin objects
- $criteria = new Criteria(AdminPeer::DATABASE_NAME);
-
- $criteria->add(AdminPeer::ID, $obj->getAdminId());
- $affectedRows += AdminPeer::doDelete($criteria, $con);
-
- // delete related Group objects
- $criteria = new Criteria(GroupPeer::DATABASE_NAME);
-
- $criteria->add(GroupPeer::ID, $obj->getGroupId());
- $affectedRows += GroupPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given AdminGroup object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php
index 42dcdf9cf..220fb9bb5 100644
--- a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php
@@ -39,14 +39,14 @@ use Thelia\Model\Group;
* @method AdminGroupQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method AdminGroupQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method AdminGroupQuery leftJoinAdmin($relationAlias = null) Adds a LEFT JOIN clause to the query using the Admin relation
- * @method AdminGroupQuery rightJoinAdmin($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Admin relation
- * @method AdminGroupQuery innerJoinAdmin($relationAlias = null) Adds a INNER JOIN clause to the query using the Admin relation
- *
* @method AdminGroupQuery leftJoinGroup($relationAlias = null) Adds a LEFT JOIN clause to the query using the Group relation
* @method AdminGroupQuery rightJoinGroup($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Group relation
* @method AdminGroupQuery innerJoinGroup($relationAlias = null) Adds a INNER JOIN clause to the query using the Group relation
*
+ * @method AdminGroupQuery leftJoinAdmin($relationAlias = null) Adds a LEFT JOIN clause to the query using the Admin relation
+ * @method AdminGroupQuery rightJoinAdmin($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Admin relation
+ * @method AdminGroupQuery innerJoinAdmin($relationAlias = null) Adds a INNER JOIN clause to the query using the Admin relation
+ *
* @method AdminGroup findOne(PropelPDO $con = null) Return the first AdminGroup matching the query
* @method AdminGroup findOneOrCreate(PropelPDO $con = null) Return the first AdminGroup matching the query, or a new AdminGroup object populated from the query conditions when no match is found
*
@@ -73,7 +73,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\AdminGroup', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\AdminGroup', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -276,6 +276,8 @@ abstract class BaseAdminGroupQuery extends ModelCriteria
* $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
*
*
+ * @see filterByGroup()
+ *
* @param mixed $groupId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -317,6 +319,8 @@ abstract class BaseAdminGroupQuery extends ModelCriteria
* $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12
*
*
+ * @see filterByAdmin()
+ *
* @param mixed $adminId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -434,84 +438,10 @@ abstract class BaseAdminGroupQuery extends ModelCriteria
return $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt, $comparison);
}
- /**
- * Filter the query by a related Admin object
- *
- * @param Admin|PropelObjectCollection $admin the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return AdminGroupQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByAdmin($admin, $comparison = null)
- {
- if ($admin instanceof Admin) {
- return $this
- ->addUsingAlias(AdminGroupPeer::ADMIN_ID, $admin->getId(), $comparison);
- } elseif ($admin instanceof PropelObjectCollection) {
- return $this
- ->useAdminQuery()
- ->filterByPrimaryKeys($admin->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByAdmin() only accepts arguments of type Admin or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Admin relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return AdminGroupQuery The current query, for fluid interface
- */
- public function joinAdmin($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Admin');
-
- // 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, 'Admin');
- }
-
- return $this;
- }
-
- /**
- * Use the Admin relation Admin 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\AdminQuery A secondary query class using the current class as primary query
- */
- public function useAdminQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinAdmin($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery');
- }
-
/**
* Filter the query by a related Group object
*
- * @param Group|PropelObjectCollection $group the related object to use as filter
+ * @param Group|PropelObjectCollection $group The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AdminGroupQuery The current query, for fluid interface
@@ -523,10 +453,12 @@ abstract class BaseAdminGroupQuery extends ModelCriteria
return $this
->addUsingAlias(AdminGroupPeer::GROUP_ID, $group->getId(), $comparison);
} elseif ($group instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useGroupQuery()
- ->filterByPrimaryKeys($group->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AdminGroupPeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
}
@@ -540,7 +472,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria
*
* @return AdminGroupQuery The current query, for fluid interface
*/
- public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinGroup($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Group');
@@ -575,13 +507,89 @@ abstract class BaseAdminGroupQuery extends ModelCriteria
*
* @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query
*/
- public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useGroupQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinGroup($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
}
+ /**
+ * Filter the query by a related Admin object
+ *
+ * @param Admin|PropelObjectCollection $admin The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAdmin($admin, $comparison = null)
+ {
+ if ($admin instanceof Admin) {
+ return $this
+ ->addUsingAlias(AdminGroupPeer::ADMIN_ID, $admin->getId(), $comparison);
+ } elseif ($admin instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AdminGroupPeer::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAdmin() only accepts arguments of type Admin or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Admin relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function joinAdmin($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Admin');
+
+ // 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, 'Admin');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Admin relation Admin 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\AdminQuery A secondary query class using the current class as primary query
+ */
+ public function useAdminQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinAdmin($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseAdminLogPeer.php b/core/lib/Thelia/Model/om/BaseAdminLogPeer.php
index 4f24ef0ab..c4c775b06 100644
--- a/core/lib/Thelia/Model/om/BaseAdminLogPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAdminLogPeer.php
@@ -24,7 +24,7 @@ abstract class BaseAdminLogPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'admin_log';
diff --git a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php
index 3cdf28c19..c36a80193 100644
--- a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php
@@ -73,7 +73,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\AdminLog', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\AdminLog', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
diff --git a/core/lib/Thelia/Model/om/BaseAdminPeer.php b/core/lib/Thelia/Model/om/BaseAdminPeer.php
index f2fd410a9..e134a3161 100644
--- a/core/lib/Thelia/Model/om/BaseAdminPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAdminPeer.php
@@ -25,7 +25,7 @@ abstract class BaseAdminPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'admin';
@@ -403,6 +403,9 @@ abstract class BaseAdminPeer
*/
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();
}
/**
@@ -499,245 +502,6 @@ abstract class BaseAdminPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related AdminGroup table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAdminGroup(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AdminPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AdminPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AdminPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AdminPeer::ID, AdminGroupPeer::ADMIN_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Admin objects pre-filled with their AdminGroup objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Admin objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAdminGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AdminPeer::DATABASE_NAME);
- }
-
- AdminPeer::addSelectColumns($criteria);
- $startcol = AdminPeer::NUM_HYDRATE_COLUMNS;
- AdminGroupPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(AdminPeer::ID, AdminGroupPeer::ADMIN_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AdminPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AdminPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = AdminPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AdminPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AdminGroupPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AdminGroupPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AdminGroupPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Admin) to $obj2 (AdminGroup)
- // one to one relationship
- $obj1->setAdminGroup($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AdminPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AdminPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AdminPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AdminPeer::ID, AdminGroupPeer::ADMIN_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Admin objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Admin objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AdminPeer::DATABASE_NAME);
- }
-
- AdminPeer::addSelectColumns($criteria);
- $startcol2 = AdminPeer::NUM_HYDRATE_COLUMNS;
-
- AdminGroupPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AdminGroupPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AdminPeer::ID, AdminGroupPeer::ADMIN_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AdminPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AdminPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AdminPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AdminPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AdminGroup rows
-
- $key2 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AdminGroupPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AdminGroupPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AdminGroupPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Admin) to the collection in $obj2 (AdminGroup)
- $obj1->setAdminGroup($obj2);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseAdminQuery.php b/core/lib/Thelia/Model/om/BaseAdminQuery.php
index ffb5b6837..1d895ffcf 100644
--- a/core/lib/Thelia/Model/om/BaseAdminQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAdminQuery.php
@@ -84,7 +84,7 @@ abstract class BaseAdminQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Admin', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Admin', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -260,8 +260,6 @@ abstract class BaseAdminQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAdminGroup()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -542,7 +540,7 @@ abstract class BaseAdminQuery extends ModelCriteria
/**
* Filter the query by a related AdminGroup object
*
- * @param AdminGroup|PropelObjectCollection $adminGroup The related object(s) 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 AdminQuery The current query, for fluid interface
@@ -554,12 +552,10 @@ abstract class BaseAdminQuery extends ModelCriteria
return $this
->addUsingAlias(AdminPeer::ID, $adminGroup->getAdminId(), $comparison);
} elseif ($adminGroup instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AdminPeer::ID, $adminGroup->toKeyValue('PrimaryKey', 'AdminId'), $comparison);
+ ->useAdminGroupQuery()
+ ->filterByPrimaryKeys($adminGroup->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection');
}
@@ -573,7 +569,7 @@ abstract class BaseAdminQuery extends ModelCriteria
*
* @return AdminQuery The current query, for fluid interface
*/
- public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinAdminGroup($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('AdminGroup');
@@ -608,7 +604,7 @@ abstract class BaseAdminQuery extends ModelCriteria
*
* @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query
*/
- public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinAdminGroup($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseArea.php b/core/lib/Thelia/Model/om/BaseArea.php
index 3f906ca17..15f4ff9df 100644
--- a/core/lib/Thelia/Model/om/BaseArea.php
+++ b/core/lib/Thelia/Model/om/BaseArea.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Area;
use Thelia\Model\AreaPeer;
@@ -80,14 +82,16 @@ abstract class BaseArea extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Country
+ * @var PropelObjectCollection|Country[] Collection to store aggregation of Country objects.
*/
- protected $aCountry;
+ protected $collCountrys;
+ protected $collCountrysPartial;
/**
- * @var Delivzone
+ * @var PropelObjectCollection|Delivzone[] Collection to store aggregation of Delivzone objects.
*/
- protected $aDelivzone;
+ protected $collDelivzones;
+ protected $collDelivzonesPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -103,6 +107,18 @@ abstract class BaseArea extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $countrysScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $delivzonesScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -224,14 +240,6 @@ abstract class BaseArea extends BaseObject implements Persistent
$this->modifiedColumns[] = AreaPeer::ID;
}
- if ($this->aCountry !== null && $this->aCountry->getAreaId() !== $v) {
- $this->aCountry = null;
- }
-
- if ($this->aDelivzone !== null && $this->aDelivzone->getAreaId() !== $v) {
- $this->aDelivzone = null;
- }
-
return $this;
} // setId()
@@ -392,12 +400,6 @@ abstract class BaseArea extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aCountry !== null && $this->id !== $this->aCountry->getAreaId()) {
- $this->aCountry = null;
- }
- if ($this->aDelivzone !== null && $this->id !== $this->aDelivzone->getAreaId()) {
- $this->aDelivzone = null;
- }
} // ensureConsistency
/**
@@ -437,8 +439,10 @@ abstract class BaseArea extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aCountry = null;
- $this->aDelivzone = null;
+ $this->collCountrys = null;
+
+ $this->collDelivzones = null;
+
} // if (deep)
}
@@ -552,25 +556,6 @@ abstract class BaseArea extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aCountry !== null) {
- if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
- $affectedRows += $this->aCountry->save($con);
- }
- $this->setCountry($this->aCountry);
- }
-
- if ($this->aDelivzone !== null) {
- if ($this->aDelivzone->isModified() || $this->aDelivzone->isNew()) {
- $affectedRows += $this->aDelivzone->save($con);
- }
- $this->setDelivzone($this->aDelivzone);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -582,6 +567,42 @@ abstract class BaseArea extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->countrysScheduledForDeletion !== null) {
+ if (!$this->countrysScheduledForDeletion->isEmpty()) {
+ foreach ($this->countrysScheduledForDeletion as $country) {
+ // need to save related object because we set the relation to null
+ $country->save($con);
+ }
+ $this->countrysScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCountrys !== null) {
+ foreach ($this->collCountrys as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->delivzonesScheduledForDeletion !== null) {
+ if (!$this->delivzonesScheduledForDeletion->isEmpty()) {
+ foreach ($this->delivzonesScheduledForDeletion as $delivzone) {
+ // need to save related object because we set the relation to null
+ $delivzone->save($con);
+ }
+ $this->delivzonesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collDelivzones !== null) {
+ foreach ($this->collDelivzones as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -743,29 +764,27 @@ abstract class BaseArea extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aCountry !== null) {
- if (!$this->aCountry->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aCountry->getValidationFailures());
- }
- }
-
- if ($this->aDelivzone !== null) {
- if (!$this->aDelivzone->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aDelivzone->getValidationFailures());
- }
- }
-
-
if (($retval = AreaPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collCountrys !== null) {
+ foreach ($this->collCountrys as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collDelivzones !== null) {
+ foreach ($this->collDelivzones as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -852,11 +871,11 @@ abstract class BaseArea extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aCountry) {
- $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collCountrys) {
+ $result['Countrys'] = $this->collCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aDelivzone) {
- $result['Delivzone'] = $this->aDelivzone->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collDelivzones) {
+ $result['Delivzones'] = $this->collDelivzones->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1027,14 +1046,16 @@ abstract class BaseArea extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCountry();
- if ($relObj) {
- $copyObj->setCountry($relObj->copy($deepCopy));
+ foreach ($this->getCountrys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCountry($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getDelivzone();
- if ($relObj) {
- $copyObj->setDelivzone($relObj->copy($deepCopy));
+ foreach ($this->getDelivzones() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDelivzone($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1087,98 +1108,437 @@ abstract class BaseArea extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a Country object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param Country $v
- * @return Area The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Country' == $relationName) {
+ $this->initCountrys();
+ }
+ if ('Delivzone' == $relationName) {
+ $this->initDelivzones();
+ }
+ }
+
+ /**
+ * Clears out the collCountrys 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 addCountrys()
+ */
+ public function clearCountrys()
+ {
+ $this->collCountrys = null; // important to set this to null since that means it is uninitialized
+ $this->collCountrysPartial = null;
+ }
+
+ /**
+ * reset is the collCountrys collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialCountrys($v = true)
+ {
+ $this->collCountrysPartial = $v;
+ }
+
+ /**
+ * Initializes the collCountrys collection.
+ *
+ * By default this just sets the collCountrys collection to an empty array (like clearcollCountrys());
+ * 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 initCountrys($overrideExisting = true)
+ {
+ if (null !== $this->collCountrys && !$overrideExisting) {
+ return;
+ }
+ $this->collCountrys = new PropelObjectCollection();
+ $this->collCountrys->setModel('Country');
+ }
+
+ /**
+ * Gets an array of Country 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 Area 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|Country[] List of Country objects
* @throws PropelException
*/
- public function setCountry(Country $v = null)
+ public function getCountrys($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collCountrysPartial && !$this->isNew();
+ if (null === $this->collCountrys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCountrys) {
+ // return empty collection
+ $this->initCountrys();
+ } else {
+ $collCountrys = CountryQuery::create(null, $criteria)
+ ->filterByArea($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCountrysPartial && count($collCountrys)) {
+ $this->initCountrys(false);
+
+ foreach($collCountrys as $obj) {
+ if (false == $this->collCountrys->contains($obj)) {
+ $this->collCountrys->append($obj);
+ }
+ }
+
+ $this->collCountrysPartial = true;
+ }
+
+ return $collCountrys;
+ }
+
+ if($partial && $this->collCountrys) {
+ foreach($this->collCountrys as $obj) {
+ if($obj->isNew()) {
+ $collCountrys[] = $obj;
+ }
+ }
+ }
+
+ $this->collCountrys = $collCountrys;
+ $this->collCountrysPartial = false;
+ }
+ }
+
+ return $this->collCountrys;
+ }
+
+ /**
+ * Sets a collection of Country 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 $countrys A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setCountrys(PropelCollection $countrys, PropelPDO $con = null)
+ {
+ $this->countrysScheduledForDeletion = $this->getCountrys(new Criteria(), $con)->diff($countrys);
+
+ foreach ($this->countrysScheduledForDeletion as $countryRemoved) {
+ $countryRemoved->setArea(null);
+ }
+
+ $this->collCountrys = null;
+ foreach ($countrys as $country) {
+ $this->addCountry($country);
+ }
+
+ $this->collCountrys = $countrys;
+ $this->collCountrysPartial = false;
+ }
+
+ /**
+ * Returns the number of related Country objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Country objects.
+ * @throws PropelException
+ */
+ public function countCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCountrysPartial && !$this->isNew();
+ if (null === $this->collCountrys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCountrys) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getCountrys());
+ }
+ $query = CountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByArea($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getAreaId());
+ return count($this->collCountrys);
}
+ }
- $this->aCountry = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setArea($this);
+ /**
+ * Method called to associate a Country object to this object
+ * through the Country foreign key attribute.
+ *
+ * @param Country $l Country
+ * @return Area The current object (for fluent API support)
+ */
+ public function addCountry(Country $l)
+ {
+ if ($this->collCountrys === null) {
+ $this->initCountrys();
+ $this->collCountrysPartial = true;
+ }
+ if (!$this->collCountrys->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddCountry($l);
}
-
return $this;
}
-
/**
- * Get the associated Country object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Country The associated Country object.
- * @throws PropelException
+ * @param Country $country The country object to add.
*/
- public function getCountry(PropelPDO $con = null)
+ protected function doAddCountry($country)
{
- if ($this->aCountry === null && ($this->id !== null)) {
- $this->aCountry = CountryQuery::create()
- ->filterByArea($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aCountry->setArea($this);
- }
-
- return $this->aCountry;
+ $this->collCountrys[]= $country;
+ $country->setArea($this);
}
/**
- * Declares an association between this object and a Delivzone object.
+ * @param Country $country The country object to remove.
+ */
+ public function removeCountry($country)
+ {
+ if ($this->getCountrys()->contains($country)) {
+ $this->collCountrys->remove($this->collCountrys->search($country));
+ if (null === $this->countrysScheduledForDeletion) {
+ $this->countrysScheduledForDeletion = clone $this->collCountrys;
+ $this->countrysScheduledForDeletion->clear();
+ }
+ $this->countrysScheduledForDeletion[]= $country;
+ $country->setArea(null);
+ }
+ }
+
+ /**
+ * Clears out the collDelivzones collection
*
- * @param Delivzone $v
- * @return Area The current object (for fluent API support)
+ * 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 addDelivzones()
+ */
+ public function clearDelivzones()
+ {
+ $this->collDelivzones = null; // important to set this to null since that means it is uninitialized
+ $this->collDelivzonesPartial = null;
+ }
+
+ /**
+ * reset is the collDelivzones collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialDelivzones($v = true)
+ {
+ $this->collDelivzonesPartial = $v;
+ }
+
+ /**
+ * Initializes the collDelivzones collection.
+ *
+ * By default this just sets the collDelivzones collection to an empty array (like clearcollDelivzones());
+ * 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 initDelivzones($overrideExisting = true)
+ {
+ if (null !== $this->collDelivzones && !$overrideExisting) {
+ return;
+ }
+ $this->collDelivzones = new PropelObjectCollection();
+ $this->collDelivzones->setModel('Delivzone');
+ }
+
+ /**
+ * Gets an array of Delivzone 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 Area 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|Delivzone[] List of Delivzone objects
* @throws PropelException
*/
- public function setDelivzone(Delivzone $v = null)
+ public function getDelivzones($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collDelivzonesPartial && !$this->isNew();
+ if (null === $this->collDelivzones || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDelivzones) {
+ // return empty collection
+ $this->initDelivzones();
+ } else {
+ $collDelivzones = DelivzoneQuery::create(null, $criteria)
+ ->filterByArea($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collDelivzonesPartial && count($collDelivzones)) {
+ $this->initDelivzones(false);
+
+ foreach($collDelivzones as $obj) {
+ if (false == $this->collDelivzones->contains($obj)) {
+ $this->collDelivzones->append($obj);
+ }
+ }
+
+ $this->collDelivzonesPartial = true;
+ }
+
+ return $collDelivzones;
+ }
+
+ if($partial && $this->collDelivzones) {
+ foreach($this->collDelivzones as $obj) {
+ if($obj->isNew()) {
+ $collDelivzones[] = $obj;
+ }
+ }
+ }
+
+ $this->collDelivzones = $collDelivzones;
+ $this->collDelivzonesPartial = false;
+ }
+ }
+
+ return $this->collDelivzones;
+ }
+
+ /**
+ * Sets a collection of Delivzone 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 $delivzones A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setDelivzones(PropelCollection $delivzones, PropelPDO $con = null)
+ {
+ $this->delivzonesScheduledForDeletion = $this->getDelivzones(new Criteria(), $con)->diff($delivzones);
+
+ foreach ($this->delivzonesScheduledForDeletion as $delivzoneRemoved) {
+ $delivzoneRemoved->setArea(null);
+ }
+
+ $this->collDelivzones = null;
+ foreach ($delivzones as $delivzone) {
+ $this->addDelivzone($delivzone);
+ }
+
+ $this->collDelivzones = $delivzones;
+ $this->collDelivzonesPartial = false;
+ }
+
+ /**
+ * Returns the number of related Delivzone objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Delivzone objects.
+ * @throws PropelException
+ */
+ public function countDelivzones(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collDelivzonesPartial && !$this->isNew();
+ if (null === $this->collDelivzones || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDelivzones) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getDelivzones());
+ }
+ $query = DelivzoneQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByArea($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getAreaId());
+ return count($this->collDelivzones);
}
+ }
- $this->aDelivzone = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setArea($this);
+ /**
+ * Method called to associate a Delivzone object to this object
+ * through the Delivzone foreign key attribute.
+ *
+ * @param Delivzone $l Delivzone
+ * @return Area The current object (for fluent API support)
+ */
+ public function addDelivzone(Delivzone $l)
+ {
+ if ($this->collDelivzones === null) {
+ $this->initDelivzones();
+ $this->collDelivzonesPartial = true;
+ }
+ if (!$this->collDelivzones->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddDelivzone($l);
}
-
return $this;
}
+ /**
+ * @param Delivzone $delivzone The delivzone object to add.
+ */
+ protected function doAddDelivzone($delivzone)
+ {
+ $this->collDelivzones[]= $delivzone;
+ $delivzone->setArea($this);
+ }
/**
- * Get the associated Delivzone object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Delivzone The associated Delivzone object.
- * @throws PropelException
+ * @param Delivzone $delivzone The delivzone object to remove.
*/
- public function getDelivzone(PropelPDO $con = null)
+ public function removeDelivzone($delivzone)
{
- if ($this->aDelivzone === null && ($this->id !== null)) {
- $this->aDelivzone = DelivzoneQuery::create()
- ->filterByArea($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aDelivzone->setArea($this);
+ if ($this->getDelivzones()->contains($delivzone)) {
+ $this->collDelivzones->remove($this->collDelivzones->search($delivzone));
+ if (null === $this->delivzonesScheduledForDeletion) {
+ $this->delivzonesScheduledForDeletion = clone $this->collDelivzones;
+ $this->delivzonesScheduledForDeletion->clear();
+ }
+ $this->delivzonesScheduledForDeletion[]= $delivzone;
+ $delivzone->setArea(null);
}
-
- return $this->aDelivzone;
}
/**
@@ -1211,10 +1571,26 @@ abstract class BaseArea extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collCountrys) {
+ foreach ($this->collCountrys as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collDelivzones) {
+ foreach ($this->collDelivzones as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aCountry = null;
- $this->aDelivzone = null;
+ if ($this->collCountrys instanceof PropelCollection) {
+ $this->collCountrys->clearIterator();
+ }
+ $this->collCountrys = null;
+ if ($this->collDelivzones instanceof PropelCollection) {
+ $this->collDelivzones->clearIterator();
+ }
+ $this->collDelivzones = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAreaPeer.php b/core/lib/Thelia/Model/om/BaseAreaPeer.php
index c7d2ba5a8..509b07043 100644
--- a/core/lib/Thelia/Model/om/BaseAreaPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAreaPeer.php
@@ -26,7 +26,7 @@ abstract class BaseAreaPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'area';
@@ -384,6 +384,12 @@ abstract class BaseAreaPeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in CountryPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CountryPeer::clearInstancePool();
+ // Invalidate objects in DelivzonePeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ DelivzonePeer::clearInstancePool();
}
/**
@@ -480,639 +486,6 @@ abstract class BaseAreaPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related Country table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinCountry(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AreaPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AreaPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AreaPeer::ID, CountryPeer::AREA_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Delivzone table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinDelivzone(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AreaPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AreaPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AreaPeer::ID, DelivzonePeer::AREA_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Area objects pre-filled with their Country objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Area objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
- }
-
- AreaPeer::addSelectColumns($criteria);
- $startcol = AreaPeer::NUM_HYDRATE_COLUMNS;
- CountryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(AreaPeer::ID, CountryPeer::AREA_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AreaPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AreaPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = AreaPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AreaPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = CountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- CountryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Area) to $obj2 (Country)
- // one to one relationship
- $obj1->setCountry($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Area objects pre-filled with their Delivzone objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Area objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinDelivzone(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
- }
-
- AreaPeer::addSelectColumns($criteria);
- $startcol = AreaPeer::NUM_HYDRATE_COLUMNS;
- DelivzonePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(AreaPeer::ID, DelivzonePeer::AREA_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AreaPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AreaPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = AreaPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AreaPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = DelivzonePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = DelivzonePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = DelivzonePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- DelivzonePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Area) to $obj2 (Delivzone)
- // one to one relationship
- $obj1->setDelivzone($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AreaPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AreaPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AreaPeer::ID, CountryPeer::AREA_ID, $join_behavior);
-
- $criteria->addJoin(AreaPeer::ID, DelivzonePeer::AREA_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Area objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Area objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
- }
-
- AreaPeer::addSelectColumns($criteria);
- $startcol2 = AreaPeer::NUM_HYDRATE_COLUMNS;
-
- CountryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CountryPeer::NUM_HYDRATE_COLUMNS;
-
- DelivzonePeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + DelivzonePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AreaPeer::ID, CountryPeer::AREA_ID, $join_behavior);
-
- $criteria->addJoin(AreaPeer::ID, DelivzonePeer::AREA_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AreaPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AreaPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AreaPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AreaPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Country rows
-
- $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = CountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- CountryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Area) to the collection in $obj2 (Country)
- $obj1->setCountry($obj2);
- } // if joined row not null
-
- // Add objects for joined Delivzone rows
-
- $key3 = DelivzonePeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = DelivzonePeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = DelivzonePeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- DelivzonePeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Area) to the collection in $obj3 (Delivzone)
- $obj1->setDelivzone($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Country table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptCountry(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AreaPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AreaPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AreaPeer::ID, DelivzonePeer::AREA_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Delivzone table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptDelivzone(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AreaPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AreaPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AreaPeer::ID, CountryPeer::AREA_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Area objects pre-filled with all related objects except Country.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Area objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
- }
-
- AreaPeer::addSelectColumns($criteria);
- $startcol2 = AreaPeer::NUM_HYDRATE_COLUMNS;
-
- DelivzonePeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + DelivzonePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AreaPeer::ID, DelivzonePeer::AREA_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AreaPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AreaPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AreaPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AreaPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Delivzone rows
-
- $key2 = DelivzonePeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = DelivzonePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = DelivzonePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- DelivzonePeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Area) to the collection in $obj2 (Delivzone)
- $obj1->setDelivzone($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Area objects pre-filled with all related objects except Delivzone.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Area objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptDelivzone(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AreaPeer::DATABASE_NAME);
- }
-
- AreaPeer::addSelectColumns($criteria);
- $startcol2 = AreaPeer::NUM_HYDRATE_COLUMNS;
-
- CountryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CountryPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AreaPeer::ID, CountryPeer::AREA_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AreaPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AreaPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AreaPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AreaPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Country rows
-
- $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = CountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- CountryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Area) to the collection in $obj2 (Country)
- $obj1->setCountry($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseAreaQuery.php b/core/lib/Thelia/Model/om/BaseAreaQuery.php
index ff66a7249..3c25a0bf0 100644
--- a/core/lib/Thelia/Model/om/BaseAreaQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAreaQuery.php
@@ -73,7 +73,7 @@ abstract class BaseAreaQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Area', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Area', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -249,10 +249,6 @@ abstract class BaseAreaQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByCountry()
- *
- * @see filterByDelivzone()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -429,7 +425,7 @@ abstract class BaseAreaQuery extends ModelCriteria
/**
* Filter the query by a related Country object
*
- * @param Country|PropelObjectCollection $country The related object(s) to use as filter
+ * @param Country|PropelObjectCollection $country the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AreaQuery The current query, for fluid interface
@@ -441,12 +437,10 @@ abstract class BaseAreaQuery extends ModelCriteria
return $this
->addUsingAlias(AreaPeer::ID, $country->getAreaId(), $comparison);
} elseif ($country instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AreaPeer::ID, $country->toKeyValue('PrimaryKey', 'AreaId'), $comparison);
+ ->useCountryQuery()
+ ->filterByPrimaryKeys($country->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection');
}
@@ -460,7 +454,7 @@ abstract class BaseAreaQuery extends ModelCriteria
*
* @return AreaQuery The current query, for fluid interface
*/
- public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Country');
@@ -495,7 +489,7 @@ abstract class BaseAreaQuery extends ModelCriteria
*
* @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
*/
- public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinCountry($relationAlias, $joinType)
@@ -505,7 +499,7 @@ abstract class BaseAreaQuery extends ModelCriteria
/**
* Filter the query by a related Delivzone object
*
- * @param Delivzone|PropelObjectCollection $delivzone The related object(s) to use as filter
+ * @param Delivzone|PropelObjectCollection $delivzone the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AreaQuery The current query, for fluid interface
@@ -517,12 +511,10 @@ abstract class BaseAreaQuery extends ModelCriteria
return $this
->addUsingAlias(AreaPeer::ID, $delivzone->getAreaId(), $comparison);
} elseif ($delivzone instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AreaPeer::ID, $delivzone->toKeyValue('PrimaryKey', 'AreaId'), $comparison);
+ ->useDelivzoneQuery()
+ ->filterByPrimaryKeys($delivzone->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByDelivzone() only accepts arguments of type Delivzone or PropelCollection');
}
@@ -536,7 +528,7 @@ abstract class BaseAreaQuery extends ModelCriteria
*
* @return AreaQuery The current query, for fluid interface
*/
- public function joinDelivzone($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Delivzone');
@@ -571,7 +563,7 @@ abstract class BaseAreaQuery extends ModelCriteria
*
* @return \Thelia\Model\DelivzoneQuery A secondary query class using the current class as primary query
*/
- public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinDelivzone($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseAttribute.php b/core/lib/Thelia/Model/om/BaseAttribute.php
index 9958e0971..e695341dc 100644
--- a/core/lib/Thelia/Model/om/BaseAttribute.php
+++ b/core/lib/Thelia/Model/om/BaseAttribute.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Attribute;
use Thelia\Model\AttributeAv;
@@ -78,24 +80,28 @@ abstract class BaseAttribute extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var AttributeAv
+ * @var PropelObjectCollection|AttributeAv[] Collection to store aggregation of AttributeAv objects.
*/
- protected $aAttributeAv;
+ protected $collAttributeAvs;
+ protected $collAttributeAvsPartial;
/**
- * @var AttributeCategory
+ * @var PropelObjectCollection|AttributeCategory[] Collection to store aggregation of AttributeCategory objects.
*/
- protected $aAttributeCategory;
+ protected $collAttributeCategorys;
+ protected $collAttributeCategorysPartial;
/**
- * @var AttributeCombination
+ * @var PropelObjectCollection|AttributeCombination[] Collection to store aggregation of AttributeCombination objects.
*/
- protected $aAttributeCombination;
+ protected $collAttributeCombinations;
+ protected $collAttributeCombinationsPartial;
/**
- * @var AttributeDesc
+ * @var PropelObjectCollection|AttributeDesc[] Collection to store aggregation of AttributeDesc objects.
*/
- protected $aAttributeDesc;
+ protected $collAttributeDescs;
+ protected $collAttributeDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -111,6 +117,30 @@ abstract class BaseAttribute extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $attributeAvsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $attributeCategorysScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $attributeCombinationsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $attributeDescsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -222,22 +252,6 @@ abstract class BaseAttribute extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributePeer::ID;
}
- if ($this->aAttributeAv !== null && $this->aAttributeAv->getAttributeId() !== $v) {
- $this->aAttributeAv = null;
- }
-
- if ($this->aAttributeCategory !== null && $this->aAttributeCategory->getAttributeId() !== $v) {
- $this->aAttributeCategory = null;
- }
-
- if ($this->aAttributeCombination !== null && $this->aAttributeCombination->getAttributeId() !== $v) {
- $this->aAttributeCombination = null;
- }
-
- if ($this->aAttributeDesc !== null && $this->aAttributeDesc->getAttributeId() !== $v) {
- $this->aAttributeDesc = null;
- }
-
return $this;
} // setId()
@@ -376,18 +390,6 @@ abstract class BaseAttribute extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAttributeAv !== null && $this->id !== $this->aAttributeAv->getAttributeId()) {
- $this->aAttributeAv = null;
- }
- if ($this->aAttributeCategory !== null && $this->id !== $this->aAttributeCategory->getAttributeId()) {
- $this->aAttributeCategory = null;
- }
- if ($this->aAttributeCombination !== null && $this->id !== $this->aAttributeCombination->getAttributeId()) {
- $this->aAttributeCombination = null;
- }
- if ($this->aAttributeDesc !== null && $this->id !== $this->aAttributeDesc->getAttributeId()) {
- $this->aAttributeDesc = null;
- }
} // ensureConsistency
/**
@@ -427,10 +429,14 @@ abstract class BaseAttribute extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAttributeAv = null;
- $this->aAttributeCategory = null;
- $this->aAttributeCombination = null;
- $this->aAttributeDesc = null;
+ $this->collAttributeAvs = null;
+
+ $this->collAttributeCategorys = null;
+
+ $this->collAttributeCombinations = null;
+
+ $this->collAttributeDescs = null;
+
} // if (deep)
}
@@ -544,39 +550,6 @@ abstract class BaseAttribute extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAttributeAv !== null) {
- if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) {
- $affectedRows += $this->aAttributeAv->save($con);
- }
- $this->setAttributeAv($this->aAttributeAv);
- }
-
- if ($this->aAttributeCategory !== null) {
- if ($this->aAttributeCategory->isModified() || $this->aAttributeCategory->isNew()) {
- $affectedRows += $this->aAttributeCategory->save($con);
- }
- $this->setAttributeCategory($this->aAttributeCategory);
- }
-
- if ($this->aAttributeCombination !== null) {
- if ($this->aAttributeCombination->isModified() || $this->aAttributeCombination->isNew()) {
- $affectedRows += $this->aAttributeCombination->save($con);
- }
- $this->setAttributeCombination($this->aAttributeCombination);
- }
-
- if ($this->aAttributeDesc !== null) {
- if ($this->aAttributeDesc->isModified() || $this->aAttributeDesc->isNew()) {
- $affectedRows += $this->aAttributeDesc->save($con);
- }
- $this->setAttributeDesc($this->aAttributeDesc);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -588,6 +561,74 @@ abstract class BaseAttribute extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->attributeAvsScheduledForDeletion !== null) {
+ if (!$this->attributeAvsScheduledForDeletion->isEmpty()) {
+ AttributeAvQuery::create()
+ ->filterByPrimaryKeys($this->attributeAvsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeAvsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeAvs !== null) {
+ foreach ($this->collAttributeAvs 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->attributeCombinationsScheduledForDeletion !== null) {
+ if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) {
+ AttributeCombinationQuery::create()
+ ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeCombinationsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -743,41 +784,43 @@ abstract class BaseAttribute extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAttributeAv !== null) {
- if (!$this->aAttributeAv->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAttributeAv->getValidationFailures());
- }
- }
-
- if ($this->aAttributeCategory !== null) {
- if (!$this->aAttributeCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAttributeCategory->getValidationFailures());
- }
- }
-
- if ($this->aAttributeCombination !== null) {
- if (!$this->aAttributeCombination->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAttributeCombination->getValidationFailures());
- }
- }
-
- if ($this->aAttributeDesc !== null) {
- if (!$this->aAttributeDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAttributeDesc->getValidationFailures());
- }
- }
-
-
if (($retval = AttributePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collAttributeAvs !== null) {
+ foreach ($this->collAttributeAvs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collAttributeCategorys !== null) {
+ foreach ($this->collAttributeCategorys as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collAttributeDescs !== null) {
+ foreach ($this->collAttributeDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -860,17 +903,17 @@ abstract class BaseAttribute extends BaseObject implements Persistent
$keys[3] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAttributeAv) {
- $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAttributeAvs) {
+ $result['AttributeAvs'] = $this->collAttributeAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aAttributeCategory) {
- $result['AttributeCategory'] = $this->aAttributeCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAttributeCategorys) {
+ $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aAttributeCombination) {
- $result['AttributeCombination'] = $this->aAttributeCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aAttributeDesc) {
- $result['AttributeDesc'] = $this->aAttributeDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAttributeDescs) {
+ $result['AttributeDescs'] = $this->collAttributeDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1035,24 +1078,28 @@ abstract class BaseAttribute extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAttributeAv();
- if ($relObj) {
- $copyObj->setAttributeAv($relObj->copy($deepCopy));
+ foreach ($this->getAttributeAvs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeAv($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getAttributeCategory();
- if ($relObj) {
- $copyObj->setAttributeCategory($relObj->copy($deepCopy));
+ 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));
+ }
}
- $relObj = $this->getAttributeCombination();
- if ($relObj) {
- $copyObj->setAttributeCombination($relObj->copy($deepCopy));
+ foreach ($this->getAttributeCombinations() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCombination($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getAttributeDesc();
- if ($relObj) {
- $copyObj->setAttributeDesc($relObj->copy($deepCopy));
+ foreach ($this->getAttributeDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeDesc($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1105,192 +1152,932 @@ abstract class BaseAttribute extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a AttributeAv object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param AttributeAv $v
- * @return Attribute The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AttributeAv' == $relationName) {
+ $this->initAttributeAvs();
+ }
+ if ('AttributeCategory' == $relationName) {
+ $this->initAttributeCategorys();
+ }
+ if ('AttributeCombination' == $relationName) {
+ $this->initAttributeCombinations();
+ }
+ if ('AttributeDesc' == $relationName) {
+ $this->initAttributeDescs();
+ }
+ }
+
+ /**
+ * Clears out the collAttributeAvs 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 addAttributeAvs()
+ */
+ public function clearAttributeAvs()
+ {
+ $this->collAttributeAvs = null; // important to set this to null since that means it is uninitialized
+ $this->collAttributeAvsPartial = null;
+ }
+
+ /**
+ * reset is the collAttributeAvs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAttributeAvs($v = true)
+ {
+ $this->collAttributeAvsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeAvs collection.
+ *
+ * By default this just sets the collAttributeAvs collection to an empty array (like clearcollAttributeAvs());
+ * 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 initAttributeAvs($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeAvs && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeAvs = new PropelObjectCollection();
+ $this->collAttributeAvs->setModel('AttributeAv');
+ }
+
+ /**
+ * Gets an array of AttributeAv 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|AttributeAv[] List of AttributeAv objects
* @throws PropelException
*/
- public function setAttributeAv(AttributeAv $v = null)
+ public function getAttributeAvs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collAttributeAvsPartial && !$this->isNew();
+ if (null === $this->collAttributeAvs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeAvs) {
+ // return empty collection
+ $this->initAttributeAvs();
+ } else {
+ $collAttributeAvs = AttributeAvQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeAvsPartial && count($collAttributeAvs)) {
+ $this->initAttributeAvs(false);
+
+ foreach($collAttributeAvs as $obj) {
+ if (false == $this->collAttributeAvs->contains($obj)) {
+ $this->collAttributeAvs->append($obj);
+ }
+ }
+
+ $this->collAttributeAvsPartial = true;
+ }
+
+ return $collAttributeAvs;
+ }
+
+ if($partial && $this->collAttributeAvs) {
+ foreach($this->collAttributeAvs as $obj) {
+ if($obj->isNew()) {
+ $collAttributeAvs[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeAvs = $collAttributeAvs;
+ $this->collAttributeAvsPartial = false;
+ }
+ }
+
+ return $this->collAttributeAvs;
+ }
+
+ /**
+ * Sets a collection of AttributeAv 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 $attributeAvs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAttributeAvs(PropelCollection $attributeAvs, PropelPDO $con = null)
+ {
+ $this->attributeAvsScheduledForDeletion = $this->getAttributeAvs(new Criteria(), $con)->diff($attributeAvs);
+
+ foreach ($this->attributeAvsScheduledForDeletion as $attributeAvRemoved) {
+ $attributeAvRemoved->setAttribute(null);
+ }
+
+ $this->collAttributeAvs = null;
+ foreach ($attributeAvs as $attributeAv) {
+ $this->addAttributeAv($attributeAv);
+ }
+
+ $this->collAttributeAvs = $attributeAvs;
+ $this->collAttributeAvsPartial = false;
+ }
+
+ /**
+ * Returns the number of related AttributeAv objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AttributeAv objects.
+ * @throws PropelException
+ */
+ public function countAttributeAvs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeAvsPartial && !$this->isNew();
+ if (null === $this->collAttributeAvs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeAvs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAttributeAvs());
+ }
+ $query = AttributeAvQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getAttributeId());
+ return count($this->collAttributeAvs);
}
+ }
- $this->aAttributeAv = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setAttribute($this);
+ /**
+ * Method called to associate a AttributeAv object to this object
+ * through the AttributeAv foreign key attribute.
+ *
+ * @param AttributeAv $l AttributeAv
+ * @return Attribute The current object (for fluent API support)
+ */
+ public function addAttributeAv(AttributeAv $l)
+ {
+ if ($this->collAttributeAvs === null) {
+ $this->initAttributeAvs();
+ $this->collAttributeAvsPartial = true;
+ }
+ if (!$this->collAttributeAvs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeAv($l);
}
-
return $this;
}
-
/**
- * Get the associated AttributeAv object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AttributeAv The associated AttributeAv object.
- * @throws PropelException
+ * @param AttributeAv $attributeAv The attributeAv object to add.
*/
- public function getAttributeAv(PropelPDO $con = null)
+ protected function doAddAttributeAv($attributeAv)
{
- if ($this->aAttributeAv === null && ($this->id !== null)) {
- $this->aAttributeAv = AttributeAvQuery::create()
- ->filterByAttribute($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAttributeAv->setAttribute($this);
- }
-
- return $this->aAttributeAv;
+ $this->collAttributeAvs[]= $attributeAv;
+ $attributeAv->setAttribute($this);
}
/**
- * Declares an association between this object and a AttributeCategory object.
+ * @param AttributeAv $attributeAv The attributeAv object to remove.
+ */
+ public function removeAttributeAv($attributeAv)
+ {
+ if ($this->getAttributeAvs()->contains($attributeAv)) {
+ $this->collAttributeAvs->remove($this->collAttributeAvs->search($attributeAv));
+ if (null === $this->attributeAvsScheduledForDeletion) {
+ $this->attributeAvsScheduledForDeletion = clone $this->collAttributeAvs;
+ $this->attributeAvsScheduledForDeletion->clear();
+ }
+ $this->attributeAvsScheduledForDeletion[]= $attributeAv;
+ $attributeAv->setAttribute(null);
+ }
+ }
+
+ /**
+ * Clears out the collAttributeCategorys collection
*
- * @param AttributeCategory $v
- * @return Attribute The current object (for fluent API support)
+ * 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 setAttributeCategory(AttributeCategory $v = null)
+ public function getAttributeCategorys($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getAttributeId());
+ return count($this->collAttributeCategorys);
}
+ }
- $this->aAttributeCategory = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setAttribute($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated AttributeCategory object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AttributeCategory The associated AttributeCategory object.
- * @throws PropelException
+ * @param AttributeCategory $attributeCategory The attributeCategory object to add.
*/
- public function getAttributeCategory(PropelPDO $con = null)
+ protected function doAddAttributeCategory($attributeCategory)
{
- if ($this->aAttributeCategory === null && ($this->id !== null)) {
- $this->aAttributeCategory = AttributeCategoryQuery::create()
- ->filterByAttribute($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAttributeCategory->setAttribute($this);
- }
-
- return $this->aAttributeCategory;
+ $this->collAttributeCategorys[]= $attributeCategory;
+ $attributeCategory->setAttribute($this);
}
/**
- * Declares an association between this object and a AttributeCombination object.
+ * @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.
*
- * @param AttributeCombination $v
- * @return Attribute The current object (for fluent API support)
+ * 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
+ *
+ * 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 addAttributeCombinations()
+ */
+ public function clearAttributeCombinations()
+ {
+ $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized
+ $this->collAttributeCombinationsPartial = null;
+ }
+
+ /**
+ * reset is the collAttributeCombinations collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAttributeCombinations($v = true)
+ {
+ $this->collAttributeCombinationsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCombinations collection.
+ *
+ * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations());
+ * 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 initAttributeCombinations($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCombinations && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCombinations = new PropelObjectCollection();
+ $this->collAttributeCombinations->setModel('AttributeCombination');
+ }
+
+ /**
+ * Gets an array of AttributeCombination 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|AttributeCombination[] List of AttributeCombination objects
* @throws PropelException
*/
- public function setAttributeCombination(AttributeCombination $v = null)
+ public function getAttributeCombinations($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ // return empty collection
+ $this->initAttributeCombinations();
+ } else {
+ $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) {
+ $this->initAttributeCombinations(false);
+
+ foreach($collAttributeCombinations as $obj) {
+ if (false == $this->collAttributeCombinations->contains($obj)) {
+ $this->collAttributeCombinations->append($obj);
+ }
+ }
+
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ return $collAttributeCombinations;
+ }
+
+ if($partial && $this->collAttributeCombinations) {
+ foreach($this->collAttributeCombinations as $obj) {
+ if($obj->isNew()) {
+ $collAttributeCombinations[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCombinations = $collAttributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+ }
+
+ return $this->collAttributeCombinations;
+ }
+
+ /**
+ * Sets a collection of AttributeCombination 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 $attributeCombinations A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null)
+ {
+ $this->attributeCombinationsScheduledForDeletion = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations);
+
+ foreach ($this->attributeCombinationsScheduledForDeletion as $attributeCombinationRemoved) {
+ $attributeCombinationRemoved->setAttribute(null);
+ }
+
+ $this->collAttributeCombinations = null;
+ foreach ($attributeCombinations as $attributeCombination) {
+ $this->addAttributeCombination($attributeCombination);
+ }
+
+ $this->collAttributeCombinations = $attributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+
+ /**
+ * Returns the number of related AttributeCombination objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AttributeCombination objects.
+ * @throws PropelException
+ */
+ public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAttributeCombinations());
+ }
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getAttributeId());
+ return count($this->collAttributeCombinations);
}
+ }
- $this->aAttributeCombination = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setAttribute($this);
+ /**
+ * Method called to associate a AttributeCombination object to this object
+ * through the AttributeCombination foreign key attribute.
+ *
+ * @param AttributeCombination $l AttributeCombination
+ * @return Attribute The current object (for fluent API support)
+ */
+ public function addAttributeCombination(AttributeCombination $l)
+ {
+ if ($this->collAttributeCombinations === null) {
+ $this->initAttributeCombinations();
+ $this->collAttributeCombinationsPartial = true;
+ }
+ if (!$this->collAttributeCombinations->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCombination($l);
}
-
return $this;
}
-
/**
- * Get the associated AttributeCombination object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AttributeCombination The associated AttributeCombination object.
- * @throws PropelException
+ * @param AttributeCombination $attributeCombination The attributeCombination object to add.
*/
- public function getAttributeCombination(PropelPDO $con = null)
+ protected function doAddAttributeCombination($attributeCombination)
{
- if ($this->aAttributeCombination === null && ($this->id !== null)) {
- $this->aAttributeCombination = AttributeCombinationQuery::create()
- ->filterByAttribute($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAttributeCombination->setAttribute($this);
- }
-
- return $this->aAttributeCombination;
+ $this->collAttributeCombinations[]= $attributeCombination;
+ $attributeCombination->setAttribute($this);
}
/**
- * Declares an association between this object and a AttributeDesc object.
+ * @param AttributeCombination $attributeCombination The attributeCombination object to remove.
+ */
+ public function removeAttributeCombination($attributeCombination)
+ {
+ if ($this->getAttributeCombinations()->contains($attributeCombination)) {
+ $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination));
+ if (null === $this->attributeCombinationsScheduledForDeletion) {
+ $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations;
+ $this->attributeCombinationsScheduledForDeletion->clear();
+ }
+ $this->attributeCombinationsScheduledForDeletion[]= $attributeCombination;
+ $attributeCombination->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 AttributeCombinations from storage.
*
- * @param AttributeDesc $v
- * @return Attribute The current object (for fluent API support)
+ * 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|AttributeCombination[] List of AttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('AttributeAv', $join_behavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+
+ /**
+ * 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 AttributeCombinations 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|AttributeCombination[] List of AttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('Combination', $join_behavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+ /**
+ * 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 setAttributeDesc(AttributeDesc $v = null)
+ public function getAttributeDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getAttributeId());
+ return count($this->collAttributeDescs);
}
+ }
- $this->aAttributeDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setAttribute($this);
+ /**
+ * 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);
+ }
/**
- * Get the associated AttributeDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AttributeDesc The associated AttributeDesc object.
- * @throws PropelException
+ * @param AttributeDesc $attributeDesc The attributeDesc object to remove.
*/
- public function getAttributeDesc(PropelPDO $con = null)
+ public function removeAttributeDesc($attributeDesc)
{
- if ($this->aAttributeDesc === null && ($this->id !== null)) {
- $this->aAttributeDesc = AttributeDescQuery::create()
- ->filterByAttribute($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAttributeDesc->setAttribute($this);
+ 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);
}
-
- return $this->aAttributeDesc;
}
/**
@@ -1322,12 +2109,44 @@ abstract class BaseAttribute extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collAttributeAvs) {
+ foreach ($this->collAttributeAvs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeCategorys) {
+ foreach ($this->collAttributeCategorys as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeDescs) {
+ foreach ($this->collAttributeDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aAttributeAv = null;
- $this->aAttributeCategory = null;
- $this->aAttributeCombination = null;
- $this->aAttributeDesc = null;
+ 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;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAv.php b/core/lib/Thelia/Model/om/BaseAttributeAv.php
index 1bf407cc0..b99f10b08 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeAv.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeAv.php
@@ -84,19 +84,21 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var AttributeAvDesc
+ * @var Attribute
*/
- protected $aAttributeAvDesc;
+ protected $aAttribute;
/**
- * @var AttributeCombination
+ * @var PropelObjectCollection|AttributeAvDesc[] Collection to store aggregation of AttributeAvDesc objects.
*/
- protected $aAttributeCombination;
+ protected $collAttributeAvDescs;
+ protected $collAttributeAvDescsPartial;
/**
- * @var Attribute one-to-one related Attribute object
+ * @var PropelObjectCollection|AttributeCombination[] Collection to store aggregation of AttributeCombination objects.
*/
- protected $singleAttribute;
+ protected $collAttributeCombinations;
+ protected $collAttributeCombinationsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,7 +118,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $attributesScheduledForDeletion = null;
+ protected $attributeAvDescsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $attributeCombinationsScheduledForDeletion = null;
/**
* Get the [id] column value.
@@ -239,14 +247,6 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeAvPeer::ID;
}
- if ($this->aAttributeAvDesc !== null && $this->aAttributeAvDesc->getAttributeAvId() !== $v) {
- $this->aAttributeAvDesc = null;
- }
-
- if ($this->aAttributeCombination !== null && $this->aAttributeCombination->getAttributeAvId() !== $v) {
- $this->aAttributeCombination = null;
- }
-
return $this;
} // setId()
@@ -268,6 +268,10 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeAvPeer::ATTRIBUTE_ID;
}
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
return $this;
} // setAttributeId()
@@ -407,11 +411,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAttributeAvDesc !== null && $this->id !== $this->aAttributeAvDesc->getAttributeAvId()) {
- $this->aAttributeAvDesc = null;
- }
- if ($this->aAttributeCombination !== null && $this->id !== $this->aAttributeCombination->getAttributeAvId()) {
- $this->aAttributeCombination = null;
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
}
} // ensureConsistency
@@ -452,9 +453,10 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAttributeAvDesc = null;
- $this->aAttributeCombination = null;
- $this->singleAttribute = null;
+ $this->aAttribute = null;
+ $this->collAttributeAvDescs = null;
+
+ $this->collAttributeCombinations = null;
} // if (deep)
}
@@ -574,18 +576,11 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aAttributeAvDesc !== null) {
- if ($this->aAttributeAvDesc->isModified() || $this->aAttributeAvDesc->isNew()) {
- $affectedRows += $this->aAttributeAvDesc->save($con);
+ if ($this->aAttribute !== null) {
+ if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) {
+ $affectedRows += $this->aAttribute->save($con);
}
- $this->setAttributeAvDesc($this->aAttributeAvDesc);
- }
-
- if ($this->aAttributeCombination !== null) {
- if ($this->aAttributeCombination->isModified() || $this->aAttributeCombination->isNew()) {
- $affectedRows += $this->aAttributeCombination->save($con);
- }
- $this->setAttributeCombination($this->aAttributeCombination);
+ $this->setAttribute($this->aAttribute);
}
if ($this->isNew() || $this->isModified()) {
@@ -599,18 +594,37 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->attributesScheduledForDeletion !== null) {
- if (!$this->attributesScheduledForDeletion->isEmpty()) {
- AttributeQuery::create()
- ->filterByPrimaryKeys($this->attributesScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->attributeAvDescsScheduledForDeletion !== null) {
+ if (!$this->attributeAvDescsScheduledForDeletion->isEmpty()) {
+ AttributeAvDescQuery::create()
+ ->filterByPrimaryKeys($this->attributeAvDescsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->attributesScheduledForDeletion = null;
+ $this->attributeAvDescsScheduledForDeletion = null;
}
}
- if ($this->singleAttribute !== null) {
- if (!$this->singleAttribute->isDeleted()) {
- $affectedRows += $this->singleAttribute->save($con);
+ if ($this->collAttributeAvDescs !== null) {
+ foreach ($this->collAttributeAvDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->attributeCombinationsScheduledForDeletion !== null) {
+ if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) {
+ AttributeCombinationQuery::create()
+ ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeCombinationsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
}
}
@@ -780,15 +794,9 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aAttributeAvDesc !== null) {
- if (!$this->aAttributeAvDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAttributeAvDesc->getValidationFailures());
- }
- }
-
- if ($this->aAttributeCombination !== null) {
- if (!$this->aAttributeCombination->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAttributeCombination->getValidationFailures());
+ if ($this->aAttribute !== null) {
+ if (!$this->aAttribute->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aAttribute->getValidationFailures());
}
}
@@ -798,9 +806,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
}
- if ($this->singleAttribute !== null) {
- if (!$this->singleAttribute->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleAttribute->getValidationFailures());
+ if ($this->collAttributeAvDescs !== null) {
+ foreach ($this->collAttributeAvDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
}
}
@@ -890,14 +908,14 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAttributeAvDesc) {
- $result['AttributeAvDesc'] = $this->aAttributeAvDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->aAttributeCombination) {
- $result['AttributeCombination'] = $this->aAttributeCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAttributeAvDescs) {
+ $result['AttributeAvDescs'] = $this->collAttributeAvDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->singleAttribute) {
- $result['Attribute'] = $this->singleAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1068,19 +1086,16 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAttribute();
- if ($relObj) {
- $copyObj->setAttribute($relObj->copy($deepCopy));
+ foreach ($this->getAttributeAvDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeAvDesc($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getAttributeAvDesc();
- if ($relObj) {
- $copyObj->setAttributeAvDesc($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getAttributeCombination();
- if ($relObj) {
- $copyObj->setAttributeCombination($relObj->copy($deepCopy));
+ foreach ($this->getAttributeCombinations() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCombination($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1134,25 +1149,26 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a AttributeAvDesc object.
+ * Declares an association between this object and a Attribute object.
*
- * @param AttributeAvDesc $v
+ * @param Attribute $v
* @return AttributeAv The current object (for fluent API support)
* @throws PropelException
*/
- public function setAttributeAvDesc(AttributeAvDesc $v = null)
+ public function setAttribute(Attribute $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setAttributeId(NULL);
} else {
- $this->setId($v->getAttributeAvId());
+ $this->setAttributeId($v->getId());
}
- $this->aAttributeAvDesc = $v;
+ $this->aAttribute = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Attribute object, it will not be re-added.
if ($v !== null) {
- $v->setAttributeAv($this);
+ $v->addAttributeAv($this);
}
@@ -1161,70 +1177,26 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
/**
- * Get the associated AttributeAvDesc object
+ * Get the associated Attribute object
*
* @param PropelPDO $con Optional Connection object.
- * @return AttributeAvDesc The associated AttributeAvDesc object.
+ * @return Attribute The associated Attribute object.
* @throws PropelException
*/
- public function getAttributeAvDesc(PropelPDO $con = null)
+ public function getAttribute(PropelPDO $con = null)
{
- if ($this->aAttributeAvDesc === null && ($this->id !== null)) {
- $this->aAttributeAvDesc = AttributeAvDescQuery::create()
- ->filterByAttributeAv($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAttributeAvDesc->setAttributeAv($this);
+ if ($this->aAttribute === null && ($this->attribute_id !== null)) {
+ $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_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->aAttribute->addAttributeAvs($this);
+ */
}
- return $this->aAttributeAvDesc;
- }
-
- /**
- * Declares an association between this object and a AttributeCombination object.
- *
- * @param AttributeCombination $v
- * @return AttributeAv The current object (for fluent API support)
- * @throws PropelException
- */
- public function setAttributeCombination(AttributeCombination $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getAttributeAvId());
- }
-
- $this->aAttributeCombination = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setAttributeAv($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated AttributeCombination object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AttributeCombination The associated AttributeCombination object.
- * @throws PropelException
- */
- public function getAttributeCombination(PropelPDO $con = null)
- {
- if ($this->aAttributeCombination === null && ($this->id !== null)) {
- $this->aAttributeCombination = AttributeCombinationQuery::create()
- ->filterByAttributeAv($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAttributeCombination->setAttributeAv($this);
- }
-
- return $this->aAttributeCombination;
+ return $this->aAttribute;
}
@@ -1238,44 +1210,478 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ if ('AttributeAvDesc' == $relationName) {
+ $this->initAttributeAvDescs();
+ }
+ if ('AttributeCombination' == $relationName) {
+ $this->initAttributeCombinations();
+ }
}
/**
- * Gets a single Attribute object, which is related to this object by a one-to-one relationship.
+ * Clears out the collAttributeAvDescs 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 addAttributeAvDescs()
+ */
+ public function clearAttributeAvDescs()
+ {
+ $this->collAttributeAvDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collAttributeAvDescsPartial = null;
+ }
+
+ /**
+ * reset is the collAttributeAvDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAttributeAvDescs($v = true)
+ {
+ $this->collAttributeAvDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeAvDescs collection.
+ *
+ * By default this just sets the collAttributeAvDescs collection to an empty array (like clearcollAttributeAvDescs());
+ * 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 initAttributeAvDescs($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeAvDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeAvDescs = new PropelObjectCollection();
+ $this->collAttributeAvDescs->setModel('AttributeAvDesc');
+ }
+
+ /**
+ * Gets an array of AttributeAvDesc 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 AttributeAv 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 Attribute
+ * @return PropelObjectCollection|AttributeAvDesc[] List of AttributeAvDesc objects
* @throws PropelException
*/
- public function getAttribute(PropelPDO $con = null)
+ public function getAttributeAvDescs($criteria = null, PropelPDO $con = null)
{
+ $partial = $this->collAttributeAvDescsPartial && !$this->isNew();
+ if (null === $this->collAttributeAvDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeAvDescs) {
+ // return empty collection
+ $this->initAttributeAvDescs();
+ } else {
+ $collAttributeAvDescs = AttributeAvDescQuery::create(null, $criteria)
+ ->filterByAttributeAv($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeAvDescsPartial && count($collAttributeAvDescs)) {
+ $this->initAttributeAvDescs(false);
- if ($this->singleAttribute === null && !$this->isNew()) {
- $this->singleAttribute = AttributeQuery::create()->findPk($this->getPrimaryKey(), $con);
+ foreach($collAttributeAvDescs as $obj) {
+ if (false == $this->collAttributeAvDescs->contains($obj)) {
+ $this->collAttributeAvDescs->append($obj);
+ }
+ }
+
+ $this->collAttributeAvDescsPartial = true;
+ }
+
+ return $collAttributeAvDescs;
+ }
+
+ if($partial && $this->collAttributeAvDescs) {
+ foreach($this->collAttributeAvDescs as $obj) {
+ if($obj->isNew()) {
+ $collAttributeAvDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeAvDescs = $collAttributeAvDescs;
+ $this->collAttributeAvDescsPartial = false;
+ }
}
- return $this->singleAttribute;
+ return $this->collAttributeAvDescs;
}
/**
- * Sets a single Attribute object as related to this object by a one-to-one relationship.
+ * Sets a collection of AttributeAvDesc 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 Attribute $v Attribute
- * @return AttributeAv The current object (for fluent API support)
+ * @param PropelCollection $attributeAvDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAttributeAvDescs(PropelCollection $attributeAvDescs, PropelPDO $con = null)
+ {
+ $this->attributeAvDescsScheduledForDeletion = $this->getAttributeAvDescs(new Criteria(), $con)->diff($attributeAvDescs);
+
+ foreach ($this->attributeAvDescsScheduledForDeletion as $attributeAvDescRemoved) {
+ $attributeAvDescRemoved->setAttributeAv(null);
+ }
+
+ $this->collAttributeAvDescs = null;
+ foreach ($attributeAvDescs as $attributeAvDesc) {
+ $this->addAttributeAvDesc($attributeAvDesc);
+ }
+
+ $this->collAttributeAvDescs = $attributeAvDescs;
+ $this->collAttributeAvDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related AttributeAvDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AttributeAvDesc objects.
* @throws PropelException
*/
- public function setAttribute(Attribute $v = null)
+ public function countAttributeAvDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleAttribute = $v;
+ $partial = $this->collAttributeAvDescsPartial && !$this->isNew();
+ if (null === $this->collAttributeAvDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeAvDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAttributeAvDescs());
+ }
+ $query = AttributeAvDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
- // Make sure that that the passed-in Attribute isn't already associated with this object
- if ($v !== null && $v->getAttributeAv() === null) {
- $v->setAttributeAv($this);
+ return $query
+ ->filterByAttributeAv($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAttributeAvDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a AttributeAvDesc object to this object
+ * through the AttributeAvDesc foreign key attribute.
+ *
+ * @param AttributeAvDesc $l AttributeAvDesc
+ * @return AttributeAv The current object (for fluent API support)
+ */
+ public function addAttributeAvDesc(AttributeAvDesc $l)
+ {
+ if ($this->collAttributeAvDescs === null) {
+ $this->initAttributeAvDescs();
+ $this->collAttributeAvDescsPartial = true;
+ }
+ if (!$this->collAttributeAvDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeAvDesc($l);
}
return $this;
}
+ /**
+ * @param AttributeAvDesc $attributeAvDesc The attributeAvDesc object to add.
+ */
+ protected function doAddAttributeAvDesc($attributeAvDesc)
+ {
+ $this->collAttributeAvDescs[]= $attributeAvDesc;
+ $attributeAvDesc->setAttributeAv($this);
+ }
+
+ /**
+ * @param AttributeAvDesc $attributeAvDesc The attributeAvDesc object to remove.
+ */
+ public function removeAttributeAvDesc($attributeAvDesc)
+ {
+ if ($this->getAttributeAvDescs()->contains($attributeAvDesc)) {
+ $this->collAttributeAvDescs->remove($this->collAttributeAvDescs->search($attributeAvDesc));
+ if (null === $this->attributeAvDescsScheduledForDeletion) {
+ $this->attributeAvDescsScheduledForDeletion = clone $this->collAttributeAvDescs;
+ $this->attributeAvDescsScheduledForDeletion->clear();
+ }
+ $this->attributeAvDescsScheduledForDeletion[]= $attributeAvDesc;
+ $attributeAvDesc->setAttributeAv(null);
+ }
+ }
+
+ /**
+ * Clears out the collAttributeCombinations 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 addAttributeCombinations()
+ */
+ public function clearAttributeCombinations()
+ {
+ $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized
+ $this->collAttributeCombinationsPartial = null;
+ }
+
+ /**
+ * reset is the collAttributeCombinations collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAttributeCombinations($v = true)
+ {
+ $this->collAttributeCombinationsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCombinations collection.
+ *
+ * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations());
+ * 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 initAttributeCombinations($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCombinations && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCombinations = new PropelObjectCollection();
+ $this->collAttributeCombinations->setModel('AttributeCombination');
+ }
+
+ /**
+ * Gets an array of AttributeCombination 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 AttributeAv 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|AttributeCombination[] List of AttributeCombination objects
+ * @throws PropelException
+ */
+ public function getAttributeCombinations($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ // return empty collection
+ $this->initAttributeCombinations();
+ } else {
+ $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria)
+ ->filterByAttributeAv($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) {
+ $this->initAttributeCombinations(false);
+
+ foreach($collAttributeCombinations as $obj) {
+ if (false == $this->collAttributeCombinations->contains($obj)) {
+ $this->collAttributeCombinations->append($obj);
+ }
+ }
+
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ return $collAttributeCombinations;
+ }
+
+ if($partial && $this->collAttributeCombinations) {
+ foreach($this->collAttributeCombinations as $obj) {
+ if($obj->isNew()) {
+ $collAttributeCombinations[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCombinations = $collAttributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+ }
+
+ return $this->collAttributeCombinations;
+ }
+
+ /**
+ * Sets a collection of AttributeCombination 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 $attributeCombinations A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null)
+ {
+ $this->attributeCombinationsScheduledForDeletion = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations);
+
+ foreach ($this->attributeCombinationsScheduledForDeletion as $attributeCombinationRemoved) {
+ $attributeCombinationRemoved->setAttributeAv(null);
+ }
+
+ $this->collAttributeCombinations = null;
+ foreach ($attributeCombinations as $attributeCombination) {
+ $this->addAttributeCombination($attributeCombination);
+ }
+
+ $this->collAttributeCombinations = $attributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+
+ /**
+ * Returns the number of related AttributeCombination objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AttributeCombination objects.
+ * @throws PropelException
+ */
+ public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAttributeCombinations());
+ }
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttributeAv($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAttributeCombinations);
+ }
+ }
+
+ /**
+ * Method called to associate a AttributeCombination object to this object
+ * through the AttributeCombination foreign key attribute.
+ *
+ * @param AttributeCombination $l AttributeCombination
+ * @return AttributeAv The current object (for fluent API support)
+ */
+ public function addAttributeCombination(AttributeCombination $l)
+ {
+ if ($this->collAttributeCombinations === null) {
+ $this->initAttributeCombinations();
+ $this->collAttributeCombinationsPartial = true;
+ }
+ if (!$this->collAttributeCombinations->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCombination($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to add.
+ */
+ protected function doAddAttributeCombination($attributeCombination)
+ {
+ $this->collAttributeCombinations[]= $attributeCombination;
+ $attributeCombination->setAttributeAv($this);
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to remove.
+ */
+ public function removeAttributeCombination($attributeCombination)
+ {
+ if ($this->getAttributeCombinations()->contains($attributeCombination)) {
+ $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination));
+ if (null === $this->attributeCombinationsScheduledForDeletion) {
+ $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations;
+ $this->attributeCombinationsScheduledForDeletion->clear();
+ }
+ $this->attributeCombinationsScheduledForDeletion[]= $attributeCombination;
+ $attributeCombination->setAttributeAv(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this AttributeAv is new, it will return
+ * an empty collection; or if this AttributeAv has previously
+ * been saved, it will retrieve related AttributeCombinations 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 AttributeAv.
+ *
+ * @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|AttributeCombination[] List of AttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('Attribute', $join_behavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this AttributeAv is new, it will return
+ * an empty collection; or if this AttributeAv has previously
+ * been saved, it will retrieve related AttributeCombinations 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 AttributeAv.
+ *
+ * @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|AttributeCombination[] List of AttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('Combination', $join_behavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1306,17 +1712,27 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleAttribute) {
- $this->singleAttribute->clearAllReferences($deep);
+ if ($this->collAttributeAvDescs) {
+ foreach ($this->collAttributeAvDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $o) {
+ $o->clearAllReferences($deep);
+ }
}
} // if ($deep)
- if ($this->singleAttribute instanceof PropelCollection) {
- $this->singleAttribute->clearIterator();
+ if ($this->collAttributeAvDescs instanceof PropelCollection) {
+ $this->collAttributeAvDescs->clearIterator();
}
- $this->singleAttribute = null;
- $this->aAttributeAvDesc = null;
- $this->aAttributeCombination = null;
+ $this->collAttributeAvDescs = null;
+ if ($this->collAttributeCombinations instanceof PropelCollection) {
+ $this->collAttributeCombinations->clearIterator();
+ }
+ $this->collAttributeCombinations = null;
+ $this->aAttribute = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php b/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php
index c065a49c2..32ecd67f7 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\AttributeAv;
use Thelia\Model\AttributeAvDesc;
@@ -98,9 +96,9 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var AttributeAv one-to-one related AttributeAv object
+ * @var AttributeAv
*/
- protected $singleAttributeAv;
+ protected $aAttributeAv;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $attributeAvsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -294,6 +286,10 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeAvDescPeer::ATTRIBUTE_AV_ID;
}
+ if ($this->aAttributeAv !== null && $this->aAttributeAv->getId() !== $v) {
+ $this->aAttributeAv = null;
+ }
+
return $this;
} // setAttributeAvId()
@@ -499,6 +495,9 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) {
+ $this->aAttributeAv = null;
+ }
} // ensureConsistency
/**
@@ -538,8 +537,7 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleAttributeAv = null;
-
+ $this->aAttributeAv = null;
} // if (deep)
}
@@ -653,6 +651,18 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttributeAv !== null) {
+ if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) {
+ $affectedRows += $this->aAttributeAv->save($con);
+ }
+ $this->setAttributeAv($this->aAttributeAv);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -664,21 +674,6 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->attributeAvsScheduledForDeletion !== null) {
- if (!$this->attributeAvsScheduledForDeletion->isEmpty()) {
- AttributeAvQuery::create()
- ->filterByPrimaryKeys($this->attributeAvsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->attributeAvsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleAttributeAv !== null) {
- if (!$this->singleAttributeAv->isDeleted()) {
- $affectedRows += $this->singleAttributeAv->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -858,17 +853,23 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttributeAv !== null) {
+ if (!$this->aAttributeAv->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aAttributeAv->getValidationFailures());
+ }
+ }
+
+
if (($retval = AttributeAvDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleAttributeAv !== null) {
- if (!$this->singleAttributeAv->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleAttributeAv->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -967,8 +968,8 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleAttributeAv) {
- $result['AttributeAv'] = $this->singleAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aAttributeAv) {
+ $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1157,11 +1158,6 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAttributeAv();
- if ($relObj) {
- $copyObj->setAttributeAv($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1212,55 +1208,57 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a AttributeAv object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single AttributeAv object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return AttributeAv
- * @throws PropelException
- */
- public function getAttributeAv(PropelPDO $con = null)
- {
-
- if ($this->singleAttributeAv === null && !$this->isNew()) {
- $this->singleAttributeAv = AttributeAvQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleAttributeAv;
- }
-
- /**
- * Sets a single AttributeAv object as related to this object by a one-to-one relationship.
- *
- * @param AttributeAv $v AttributeAv
+ * @param AttributeAv $v
* @return AttributeAvDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setAttributeAv(AttributeAv $v = null)
{
- $this->singleAttributeAv = $v;
-
- // Make sure that that the passed-in AttributeAv isn't already associated with this object
- if ($v !== null && $v->getAttributeAvDesc() === null) {
- $v->setAttributeAvDesc($this);
+ if ($v === null) {
+ $this->setAttributeAvId(NULL);
+ } else {
+ $this->setAttributeAvId($v->getId());
}
+ $this->aAttributeAv = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the AttributeAv object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeAvDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated AttributeAv object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return AttributeAv The associated AttributeAv object.
+ * @throws PropelException
+ */
+ public function getAttributeAv(PropelPDO $con = null)
+ {
+ if ($this->aAttributeAv === null && ($this->attribute_av_id !== null)) {
+ $this->aAttributeAv = AttributeAvQuery::create()->findPk($this->attribute_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->aAttributeAv->addAttributeAvDescs($this);
+ */
+ }
+
+ return $this->aAttributeAv;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1294,15 +1292,9 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleAttributeAv) {
- $this->singleAttributeAv->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleAttributeAv instanceof PropelCollection) {
- $this->singleAttributeAv->clearIterator();
- }
- $this->singleAttributeAv = null;
+ $this->aAttributeAv = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvDescPeer.php b/core/lib/Thelia/Model/om/BaseAttributeAvDescPeer.php
index b1cba427d..35a5dd8e2 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeAvDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseAttributeAvDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'attribute_av_desc';
@@ -398,9 +398,6 @@ abstract class BaseAttributeAvDescPeer
*/
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();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseAttributeAvDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related AttributeAv table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAttributeAv(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeAvDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeAvDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeAvDescPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of AttributeAvDesc objects pre-filled with their AttributeAv objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeAvDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAttributeAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME);
+ }
+
+ AttributeAvDescPeer::addSelectColumns($criteria);
+ $startcol = AttributeAvDescPeer::NUM_HYDRATE_COLUMNS;
+ AttributeAvPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AttributeAvDescPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeAvDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeAvDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AttributeAvDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeAvDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributeAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ AttributeAvPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AttributeAvDesc) to $obj2 (AttributeAv)
+ $obj2->addAttributeAvDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeAvDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeAvDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeAvDescPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of AttributeAvDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeAvDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME);
+ }
+
+ AttributeAvDescPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeAvDescPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributeAvPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeAvDescPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeAvDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeAvDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeAvDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeAvDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined AttributeAv rows
+
+ $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributeAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AttributeAvPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (AttributeAvDesc) to the collection in $obj2 (AttributeAv)
+ $obj2->addAttributeAvDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -630,7 +865,6 @@ abstract class BaseAttributeAvDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += AttributeAvDescPeer::doOnDeleteCascade(new Criteria(AttributeAvDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(AttributeAvDescPeer::TABLE_NAME, $con, AttributeAvDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +898,24 @@ abstract class BaseAttributeAvDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ AttributeAvDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof AttributeAvDesc) { // it's a model object
+ // invalidate the cache for this single object
+ AttributeAvDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AttributeAvDescPeer::DATABASE_NAME);
$criteria->add(AttributeAvDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AttributeAvDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,23 +928,6 @@ abstract class BaseAttributeAvDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += AttributeAvDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- AttributeAvDescPeer::clearInstancePool();
- } elseif ($values instanceof AttributeAvDesc) { // it's a model object
- AttributeAvDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- AttributeAvDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
AttributeAvDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -712,39 +939,6 @@ abstract class BaseAttributeAvDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = AttributeAvDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related AttributeAv objects
- $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME);
-
- $criteria->add(AttributeAvPeer::ID, $obj->getAttributeAvId());
- $affectedRows += AttributeAvPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given AttributeAvDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php
index dbb40ee80..09be2e38f 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseAttributeAvDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\AttributeAvDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\AttributeAvDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -283,6 +283,8 @@ abstract class BaseAttributeAvDescQuery extends ModelCriteria
* $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id > 12
*
*
+ * @see filterByAttributeAv()
+ *
* @param mixed $attributeAvId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +521,7 @@ abstract class BaseAttributeAvDescQuery extends ModelCriteria
/**
* Filter the query by a related AttributeAv object
*
- * @param AttributeAv|PropelObjectCollection $attributeAv the related object to use as filter
+ * @param AttributeAv|PropelObjectCollection $attributeAv The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeAvDescQuery The current query, for fluid interface
@@ -531,10 +533,12 @@ abstract class BaseAttributeAvDescQuery extends ModelCriteria
return $this
->addUsingAlias(AttributeAvDescPeer::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison);
} elseif ($attributeAv instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useAttributeAvQuery()
- ->filterByPrimaryKeys($attributeAv->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AttributeAvDescPeer::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php b/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php
index 31f5fb2d3..188d12186 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php
@@ -27,7 +27,7 @@ abstract class BaseAttributeAvPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'attribute_av';
@@ -385,9 +385,12 @@ abstract class BaseAttributeAvPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in AttributePeer instance pool,
+ // Invalidate objects in AttributeAvDescPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- AttributePeer::clearInstancePool();
+ AttributeAvDescPeer::clearInstancePool();
+ // Invalidate objects in AttributeCombinationPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AttributeCombinationPeer::clearInstancePool();
}
/**
@@ -486,7 +489,7 @@ abstract class BaseAttributeAvPeer
/**
- * Returns the number of rows matching criteria, joining the related AttributeAvDesc table
+ * Returns the number of rows matching criteria, joining the related Attribute table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -494,7 +497,7 @@ abstract class BaseAttributeAvPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinAttributeAvDesc(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinAttribute(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;
@@ -521,7 +524,7 @@ abstract class BaseAttributeAvPeer
$con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(AttributeAvPeer::ID, AttributeAvDescPeer::ATTRIBUTE_AV_ID, $join_behavior);
+ $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -537,58 +540,7 @@ abstract class BaseAttributeAvPeer
/**
- * Returns the number of rows matching criteria, joining the related AttributeCombination table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAttributeCombination(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributeAvPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributeAvPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of AttributeAv objects pre-filled with their AttributeAvDesc objects.
+ * Selects a collection of AttributeAv objects pre-filled with their Attribute objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -596,7 +548,7 @@ abstract class BaseAttributeAvPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinAttributeAvDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -607,9 +559,9 @@ abstract class BaseAttributeAvPeer
AttributeAvPeer::addSelectColumns($criteria);
$startcol = AttributeAvPeer::NUM_HYDRATE_COLUMNS;
- AttributeAvDescPeer::addSelectColumns($criteria);
+ AttributePeer::addSelectColumns($criteria);
- $criteria->addJoin(AttributeAvPeer::ID, AttributeAvDescPeer::ATTRIBUTE_AV_ID, $join_behavior);
+ $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -629,89 +581,20 @@ abstract class BaseAttributeAvPeer
AttributeAvPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = AttributeAvDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = AttributeAvDescPeer::getInstanceFromPool($key2);
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = AttributeAvDescPeer::getOMClass();
+ $cls = AttributePeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- AttributeAvDescPeer::addInstanceToPool($obj2, $key2);
+ AttributePeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (AttributeAv) to $obj2 (AttributeAvDesc)
- // one to one relationship
- $obj1->setAttributeAvDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of AttributeAv objects pre-filled with their AttributeCombination objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of AttributeAv objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAttributeCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
- }
-
- AttributeAvPeer::addSelectColumns($criteria);
- $startcol = AttributeAvPeer::NUM_HYDRATE_COLUMNS;
- AttributeCombinationPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributeAvPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = AttributeAvPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributeAvPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AttributeCombinationPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AttributeCombinationPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (AttributeAv) to $obj2 (AttributeCombination)
- // one to one relationship
- $obj1->setAttributeCombination($obj2);
+ // Add the $obj1 (AttributeAv) to $obj2 (Attribute)
+ $obj2->addAttributeAv($obj1);
} // if joined row was not null
@@ -759,9 +642,7 @@ abstract class BaseAttributeAvPeer
$con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(AttributeAvPeer::ID, AttributeAvDescPeer::ATTRIBUTE_AV_ID, $join_behavior);
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, $join_behavior);
+ $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -797,15 +678,10 @@ abstract class BaseAttributeAvPeer
AttributeAvPeer::addSelectColumns($criteria);
$startcol2 = AttributeAvPeer::NUM_HYDRATE_COLUMNS;
- AttributeAvDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeAvDescPeer::NUM_HYDRATE_COLUMNS;
+ AttributePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS;
- AttributeCombinationPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeAvDescPeer::ATTRIBUTE_AV_ID, $join_behavior);
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, $join_behavior);
+ $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -824,292 +700,24 @@ abstract class BaseAttributeAvPeer
AttributeAvPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined AttributeAvDesc rows
+ // Add objects for joined Attribute rows
- $key2 = AttributeAvDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = AttributeAvDescPeer::getInstanceFromPool($key2);
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = AttributeAvDescPeer::getOMClass();
+ $cls = AttributePeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- AttributeAvDescPeer::addInstanceToPool($obj2, $key2);
+ AttributePeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (AttributeAv) to the collection in $obj2 (AttributeAvDesc)
- $obj1->setAttributeAvDesc($obj2);
+ // Add the $obj1 (AttributeAv) to the collection in $obj2 (Attribute)
+ $obj2->addAttributeAv($obj1);
} // if joined row not null
- // Add objects for joined AttributeCombination rows
-
- $key3 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AttributeCombinationPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AttributeCombinationPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (AttributeAv) to the collection in $obj3 (AttributeCombination)
- $obj1->setAttributeCombination($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeAvDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAttributeAvDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributeAvPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributeAvPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCombination table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAttributeCombination(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributeAvPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributeAvPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeAvDescPeer::ATTRIBUTE_AV_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of AttributeAv objects pre-filled with all related objects except AttributeAvDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of AttributeAv objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAttributeAvDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
- }
-
- AttributeAvPeer::addSelectColumns($criteria);
- $startcol2 = AttributeAvPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCombinationPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributeAvPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AttributeAvPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributeAvPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCombination rows
-
- $key2 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCombinationPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCombinationPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (AttributeAv) to the collection in $obj2 (AttributeCombination)
- $obj1->setAttributeCombination($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of AttributeAv objects pre-filled with all related objects except AttributeCombination.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of AttributeAv objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAttributeCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
- }
-
- AttributeAvPeer::addSelectColumns($criteria);
- $startcol2 = AttributeAvPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeAvDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeAvDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AttributeAvPeer::ID, AttributeAvDescPeer::ATTRIBUTE_AV_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributeAvPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AttributeAvPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributeAvPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeAvDesc rows
-
- $key2 = AttributeAvDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeAvDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeAvDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeAvDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (AttributeAv) to the collection in $obj2 (AttributeAvDesc)
- $obj1->setAttributeAvDesc($obj2);
-
- } // if joined row is not null
-
$results[] = $obj1;
}
$stmt->closeCursor();
@@ -1250,7 +858,6 @@ abstract class BaseAttributeAvPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += AttributeAvPeer::doOnDeleteCascade(new Criteria(AttributeAvPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(AttributeAvPeer::TABLE_NAME, $con, AttributeAvPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -1284,14 +891,24 @@ abstract class BaseAttributeAvPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ AttributeAvPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof AttributeAv) { // it's a model object
+ // invalidate the cache for this single object
+ AttributeAvPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AttributeAvPeer::DATABASE_NAME);
$criteria->add(AttributeAvPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AttributeAvPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -1304,23 +921,6 @@ abstract class BaseAttributeAvPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += AttributeAvPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- AttributeAvPeer::clearInstancePool();
- } elseif ($values instanceof AttributeAv) { // it's a model object
- AttributeAvPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- AttributeAvPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
AttributeAvPeer::clearRelatedInstancePool();
$con->commit();
@@ -1332,39 +932,6 @@ abstract class BaseAttributeAvPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = AttributeAvPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Attribute objects
- $criteria = new Criteria(AttributePeer::DATABASE_NAME);
-
- $criteria->add(AttributePeer::ID, $obj->getAttributeId());
- $affectedRows += AttributePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given AttributeAv object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php
index 519300e1f..ee2538c78 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php
@@ -40,6 +40,10 @@ use Thelia\Model\AttributeCombination;
* @method AttributeAvQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method AttributeAvQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
+ * @method AttributeAvQuery leftJoinAttribute($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attribute relation
+ * @method AttributeAvQuery rightJoinAttribute($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attribute relation
+ * @method AttributeAvQuery innerJoinAttribute($relationAlias = null) Adds a INNER JOIN clause to the query using the Attribute relation
+ *
* @method AttributeAvQuery leftJoinAttributeAvDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeAvDesc relation
* @method AttributeAvQuery rightJoinAttributeAvDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeAvDesc relation
* @method AttributeAvQuery innerJoinAttributeAvDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeAvDesc relation
@@ -48,10 +52,6 @@ use Thelia\Model\AttributeCombination;
* @method AttributeAvQuery rightJoinAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCombination relation
* @method AttributeAvQuery innerJoinAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCombination relation
*
- * @method AttributeAvQuery leftJoinAttribute($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attribute relation
- * @method AttributeAvQuery rightJoinAttribute($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attribute relation
- * @method AttributeAvQuery innerJoinAttribute($relationAlias = null) Adds a INNER JOIN clause to the query using the Attribute relation
- *
* @method AttributeAv findOne(PropelPDO $con = null) Return the first AttributeAv matching the query
* @method AttributeAv findOneOrCreate(PropelPDO $con = null) Return the first AttributeAv matching the query, or a new AttributeAv object populated from the query conditions when no match is found
*
@@ -78,7 +78,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\AttributeAv', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\AttributeAv', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -254,10 +254,6 @@ abstract class BaseAttributeAvQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAttributeAvDesc()
- *
- * @see filterByAttributeCombination()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -285,6 +281,8 @@ abstract class BaseAttributeAvQuery extends ModelCriteria
* $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
*
*
+ * @see filterByAttribute()
+ *
* @param mixed $attributeId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -443,10 +441,86 @@ abstract class BaseAttributeAvQuery extends ModelCriteria
return $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query by a related Attribute object
+ *
+ * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttribute($attribute, $comparison = null)
+ {
+ if ($attribute instanceof Attribute) {
+ return $this
+ ->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison);
+ } elseif ($attribute instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Attribute relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Attribute');
+
+ // 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, 'Attribute');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Attribute relation Attribute 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\AttributeQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttribute($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
+ }
+
/**
* Filter the query by a related AttributeAvDesc object
*
- * @param AttributeAvDesc|PropelObjectCollection $attributeAvDesc The related object(s) to use as filter
+ * @param AttributeAvDesc|PropelObjectCollection $attributeAvDesc the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeAvQuery The current query, for fluid interface
@@ -458,12 +532,10 @@ abstract class BaseAttributeAvQuery extends ModelCriteria
return $this
->addUsingAlias(AttributeAvPeer::ID, $attributeAvDesc->getAttributeAvId(), $comparison);
} elseif ($attributeAvDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AttributeAvPeer::ID, $attributeAvDesc->toKeyValue('PrimaryKey', 'AttributeAvId'), $comparison);
+ ->useAttributeAvDescQuery()
+ ->filterByPrimaryKeys($attributeAvDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAttributeAvDesc() only accepts arguments of type AttributeAvDesc or PropelCollection');
}
@@ -522,7 +594,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria
/**
* Filter the query by a related AttributeCombination object
*
- * @param AttributeCombination|PropelObjectCollection $attributeCombination The related object(s) to use as filter
+ * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeAvQuery The current query, for fluid interface
@@ -534,12 +606,10 @@ abstract class BaseAttributeAvQuery extends ModelCriteria
return $this
->addUsingAlias(AttributeAvPeer::ID, $attributeCombination->getAttributeAvId(), $comparison);
} elseif ($attributeCombination instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AttributeAvPeer::ID, $attributeCombination->toKeyValue('AttributeAvId', 'AttributeAvId'), $comparison);
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection');
}
@@ -595,80 +665,6 @@ abstract class BaseAttributeAvQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery');
}
- /**
- * Filter the query by a related Attribute object
- *
- * @param Attribute|PropelObjectCollection $attribute the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return AttributeAvQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByAttribute($attribute, $comparison = null)
- {
- if ($attribute instanceof Attribute) {
- return $this
- ->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison);
- } elseif ($attribute instanceof PropelObjectCollection) {
- return $this
- ->useAttributeQuery()
- ->filterByPrimaryKeys($attribute->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Attribute relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return AttributeAvQuery The current query, for fluid interface
- */
- public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Attribute');
-
- // 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, 'Attribute');
- }
-
- return $this;
- }
-
- /**
- * Use the Attribute relation Attribute 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\AttributeQuery A secondary query class using the current class as primary query
- */
- public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinAttribute($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
- }
-
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategory.php b/core/lib/Thelia/Model/om/BaseAttributeCategory.php
index 6c7b47808..83289bb94 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeCategory.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeCategory.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Attribute;
use Thelia\Model\AttributeCategory;
@@ -82,14 +80,14 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Attribute one-to-one related Attribute object
+ * @var Category
*/
- protected $singleAttribute;
+ protected $aCategory;
/**
- * @var Category one-to-one related Category object
+ * @var Attribute
*/
- protected $singleCategory;
+ protected $aAttribute;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -105,18 +103,6 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $attributesScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $categorysScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -259,6 +245,10 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeCategoryPeer::CATEGORY_ID;
}
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
return $this;
} // setCategoryId()
@@ -280,6 +270,10 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeCategoryPeer::ATTRIBUTE_ID;
}
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
return $this;
} // setAttributeId()
@@ -398,6 +392,12 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
} // ensureConsistency
/**
@@ -437,10 +437,8 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleAttribute = null;
-
- $this->singleCategory = null;
-
+ $this->aCategory = null;
+ $this->aAttribute = null;
} // if (deep)
}
@@ -554,6 +552,25 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aAttribute !== null) {
+ if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) {
+ $affectedRows += $this->aAttribute->save($con);
+ }
+ $this->setAttribute($this->aAttribute);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -565,36 +582,6 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->attributesScheduledForDeletion !== null) {
- if (!$this->attributesScheduledForDeletion->isEmpty()) {
- AttributeQuery::create()
- ->filterByPrimaryKeys($this->attributesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->attributesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleAttribute !== null) {
- if (!$this->singleAttribute->isDeleted()) {
- $affectedRows += $this->singleAttribute->save($con);
- }
- }
-
- if ($this->categorysScheduledForDeletion !== null) {
- if (!$this->categorysScheduledForDeletion->isEmpty()) {
- CategoryQuery::create()
- ->filterByPrimaryKeys($this->categorysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->categorysScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->isDeleted()) {
- $affectedRows += $this->singleCategory->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -756,23 +743,29 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+ if ($this->aAttribute !== null) {
+ if (!$this->aAttribute->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aAttribute->getValidationFailures());
+ }
+ }
+
+
if (($retval = AttributeCategoryPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleAttribute !== null) {
- if (!$this->singleAttribute->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleAttribute->getValidationFailures());
- }
- }
-
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCategory->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -859,11 +852,11 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleAttribute) {
- $result['Attribute'] = $this->singleAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleCategory) {
- $result['Category'] = $this->singleCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1034,16 +1027,6 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAttribute();
- if ($relObj) {
- $copyObj->setAttribute($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getCategory();
- if ($relObj) {
- $copyObj->setCategory($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1094,91 +1077,108 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Category object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Attribute object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Attribute
- * @throws PropelException
- */
- public function getAttribute(PropelPDO $con = null)
- {
-
- if ($this->singleAttribute === null && !$this->isNew()) {
- $this->singleAttribute = AttributeQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleAttribute;
- }
-
- /**
- * Sets a single Attribute object as related to this object by a one-to-one relationship.
- *
- * @param Attribute $v Attribute
- * @return AttributeCategory The current object (for fluent API support)
- * @throws PropelException
- */
- public function setAttribute(Attribute $v = null)
- {
- $this->singleAttribute = $v;
-
- // Make sure that that the passed-in Attribute isn't already associated with this object
- if ($v !== null && $v->getAttributeCategory() === null) {
- $v->setAttributeCategory($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Category object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Category
- * @throws PropelException
- */
- public function getCategory(PropelPDO $con = null)
- {
-
- if ($this->singleCategory === null && !$this->isNew()) {
- $this->singleCategory = CategoryQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCategory;
- }
-
- /**
- * Sets a single Category object as related to this object by a one-to-one relationship.
- *
- * @param Category $v Category
+ * @param Category $v
* @return AttributeCategory The current object (for fluent API support)
* @throws PropelException
*/
public function setCategory(Category $v = null)
{
- $this->singleCategory = $v;
-
- // Make sure that that the passed-in Category isn't already associated with this object
- if ($v !== null && $v->getAttributeCategory() === null) {
- $v->setAttributeCategory($this);
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
}
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Category object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCategory($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Category object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Category The associated Category object.
+ * @throws PropelException
+ */
+ public function getCategory(PropelPDO $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->category_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->aCategory->addAttributeCategorys($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a Attribute object.
+ *
+ * @param Attribute $v
+ * @return AttributeCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttribute(Attribute $v = null)
+ {
+ if ($v === null) {
+ $this->setAttributeId(NULL);
+ } else {
+ $this->setAttributeId($v->getId());
+ }
+
+ $this->aAttribute = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Attribute object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCategory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Attribute object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Attribute The associated Attribute object.
+ * @throws PropelException
+ */
+ public function getAttribute(PropelPDO $con = null)
+ {
+ if ($this->aAttribute === null && ($this->attribute_id !== null)) {
+ $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_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->aAttribute->addAttributeCategorys($this);
+ */
+ }
+
+ return $this->aAttribute;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1209,22 +1209,10 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleAttribute) {
- $this->singleAttribute->clearAllReferences($deep);
- }
- if ($this->singleCategory) {
- $this->singleCategory->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleAttribute instanceof PropelCollection) {
- $this->singleAttribute->clearIterator();
- }
- $this->singleAttribute = null;
- if ($this->singleCategory instanceof PropelCollection) {
- $this->singleCategory->clearIterator();
- }
- $this->singleCategory = null;
+ $this->aCategory = null;
+ $this->aAttribute = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php
index 1acd4e248..35b5cb7b1 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php
@@ -26,7 +26,7 @@ abstract class BaseAttributeCategoryPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'attribute_category';
@@ -384,12 +384,6 @@ abstract class BaseAttributeCategoryPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in AttributePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- AttributePeer::clearInstancePool();
- // Invalidate objects in CategoryPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CategoryPeer::clearInstancePool();
}
/**
@@ -486,6 +480,637 @@ abstract class BaseAttributeCategoryPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Attribute table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAttribute(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCategory objects pre-filled with their Category objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+ }
+
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ $startcol = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AttributeCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AttributeCategory) to $obj2 (Category)
+ $obj2->addAttributeCategory($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCategory objects pre-filled with their Attribute objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+ }
+
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ $startcol = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
+ AttributePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AttributeCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ AttributePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AttributeCategory) to $obj2 (Attribute)
+ $obj2->addAttributeCategory($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of AttributeCategory objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+ }
+
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributePeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + AttributePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (AttributeCategory) to the collection in $obj2 (Category)
+ $obj2->addAttributeCategory($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Attribute rows
+
+ $key3 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = AttributePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ AttributePeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (AttributeCategory) to the collection in $obj3 (Attribute)
+ $obj3->addAttributeCategory($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Attribute table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptAttribute(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCategory objects pre-filled with all related objects except Category.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+ }
+
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Attribute rows
+
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AttributePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (AttributeCategory) to the collection in $obj2 (Attribute)
+ $obj2->addAttributeCategory($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCategory objects pre-filled with all related objects except Attribute.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+ }
+
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (AttributeCategory) to the collection in $obj2 (Category)
+ $obj2->addAttributeCategory($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -619,7 +1244,6 @@ abstract class BaseAttributeCategoryPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += AttributeCategoryPeer::doOnDeleteCascade(new Criteria(AttributeCategoryPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(AttributeCategoryPeer::TABLE_NAME, $con, AttributeCategoryPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -653,14 +1277,24 @@ abstract class BaseAttributeCategoryPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ AttributeCategoryPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof AttributeCategory) { // it's a model object
+ // invalidate the cache for this single object
+ AttributeCategoryPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME);
$criteria->add(AttributeCategoryPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AttributeCategoryPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -673,23 +1307,6 @@ abstract class BaseAttributeCategoryPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += AttributeCategoryPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- AttributeCategoryPeer::clearInstancePool();
- } elseif ($values instanceof AttributeCategory) { // it's a model object
- AttributeCategoryPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- AttributeCategoryPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
AttributeCategoryPeer::clearRelatedInstancePool();
$con->commit();
@@ -701,45 +1318,6 @@ abstract class BaseAttributeCategoryPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = AttributeCategoryPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Attribute objects
- $criteria = new Criteria(AttributePeer::DATABASE_NAME);
-
- $criteria->add(AttributePeer::ID, $obj->getAttributeId());
- $affectedRows += AttributePeer::doDelete($criteria, $con);
-
- // delete related Category objects
- $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
-
- $criteria->add(CategoryPeer::ID, $obj->getCategoryId());
- $affectedRows += CategoryPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given AttributeCategory object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php
index fccbec38e..69e02fdcb 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php
@@ -39,14 +39,14 @@ use Thelia\Model\Category;
* @method AttributeCategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method AttributeCategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method AttributeCategoryQuery leftJoinAttribute($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attribute relation
- * @method AttributeCategoryQuery rightJoinAttribute($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attribute relation
- * @method AttributeCategoryQuery innerJoinAttribute($relationAlias = null) Adds a INNER JOIN clause to the query using the Attribute relation
- *
* @method AttributeCategoryQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
* @method AttributeCategoryQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
* @method AttributeCategoryQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation
*
+ * @method AttributeCategoryQuery leftJoinAttribute($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attribute relation
+ * @method AttributeCategoryQuery rightJoinAttribute($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attribute relation
+ * @method AttributeCategoryQuery innerJoinAttribute($relationAlias = null) Adds a INNER JOIN clause to the query using the Attribute relation
+ *
* @method AttributeCategory findOne(PropelPDO $con = null) Return the first AttributeCategory matching the query
* @method AttributeCategory findOneOrCreate(PropelPDO $con = null) Return the first AttributeCategory matching the query, or a new AttributeCategory object populated from the query conditions when no match is found
*
@@ -73,7 +73,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\AttributeCategory', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\AttributeCategory', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -276,6 +276,8 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
*
*
+ * @see filterByCategory()
+ *
* @param mixed $categoryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -317,6 +319,8 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria
* $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
*
*
+ * @see filterByAttribute()
+ *
* @param mixed $attributeId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -434,84 +438,10 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria
return $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt, $comparison);
}
- /**
- * Filter the query by a related Attribute object
- *
- * @param Attribute|PropelObjectCollection $attribute the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return AttributeCategoryQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByAttribute($attribute, $comparison = null)
- {
- if ($attribute instanceof Attribute) {
- return $this
- ->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison);
- } elseif ($attribute instanceof PropelObjectCollection) {
- return $this
- ->useAttributeQuery()
- ->filterByPrimaryKeys($attribute->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Attribute relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return AttributeCategoryQuery The current query, for fluid interface
- */
- public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Attribute');
-
- // 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, 'Attribute');
- }
-
- return $this;
- }
-
- /**
- * Use the Attribute relation Attribute 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\AttributeQuery A secondary query class using the current class as primary query
- */
- public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinAttribute($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
- }
-
/**
* Filter the query by a related Category object
*
- * @param Category|PropelObjectCollection $category the related object to use as filter
+ * @param Category|PropelObjectCollection $category The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeCategoryQuery The current query, for fluid interface
@@ -523,10 +453,12 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $category->getId(), $comparison);
} elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCategoryQuery()
- ->filterByPrimaryKeys($category->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
}
@@ -582,6 +514,82 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
}
+ /**
+ * Filter the query by a related Attribute object
+ *
+ * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttribute($attribute, $comparison = null)
+ {
+ if ($attribute instanceof Attribute) {
+ return $this
+ ->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison);
+ } elseif ($attribute instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Attribute relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Attribute');
+
+ // 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, 'Attribute');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Attribute relation Attribute 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\AttributeQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttribute($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombination.php b/core/lib/Thelia/Model/om/BaseAttributeCombination.php
index f20d93978..1962f67ad 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeCombination.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeCombination.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Attribute;
use Thelia\Model\AttributeAv;
@@ -90,19 +88,19 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Attribute one-to-one related Attribute object
+ * @var Attribute
*/
- protected $singleAttribute;
+ protected $aAttribute;
/**
- * @var AttributeAv one-to-one related AttributeAv object
+ * @var AttributeAv
*/
- protected $singleAttributeAv;
+ protected $aAttributeAv;
/**
- * @var Combination one-to-one related Combination object
+ * @var Combination
*/
- protected $singleCombination;
+ protected $aCombination;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -118,24 +116,6 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $attributesScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $attributeAvsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $combinationsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -288,6 +268,10 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeCombinationPeer::ATTRIBUTE_ID;
}
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
return $this;
} // setAttributeId()
@@ -309,6 +293,10 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeCombinationPeer::COMBINATION_ID;
}
+ if ($this->aCombination !== null && $this->aCombination->getId() !== $v) {
+ $this->aCombination = null;
+ }
+
return $this;
} // setCombinationId()
@@ -330,6 +318,10 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeCombinationPeer::ATTRIBUTE_AV_ID;
}
+ if ($this->aAttributeAv !== null && $this->aAttributeAv->getId() !== $v) {
+ $this->aAttributeAv = null;
+ }
+
return $this;
} // setAttributeAvId()
@@ -449,6 +441,15 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
+ if ($this->aCombination !== null && $this->combination_id !== $this->aCombination->getId()) {
+ $this->aCombination = null;
+ }
+ if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) {
+ $this->aAttributeAv = null;
+ }
} // ensureConsistency
/**
@@ -488,12 +489,9 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleAttribute = null;
-
- $this->singleAttributeAv = null;
-
- $this->singleCombination = null;
-
+ $this->aAttribute = null;
+ $this->aAttributeAv = null;
+ $this->aCombination = null;
} // if (deep)
}
@@ -607,6 +605,32 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttribute !== null) {
+ if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) {
+ $affectedRows += $this->aAttribute->save($con);
+ }
+ $this->setAttribute($this->aAttribute);
+ }
+
+ if ($this->aAttributeAv !== null) {
+ if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) {
+ $affectedRows += $this->aAttributeAv->save($con);
+ }
+ $this->setAttributeAv($this->aAttributeAv);
+ }
+
+ if ($this->aCombination !== null) {
+ if ($this->aCombination->isModified() || $this->aCombination->isNew()) {
+ $affectedRows += $this->aCombination->save($con);
+ }
+ $this->setCombination($this->aCombination);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -618,51 +642,6 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->attributesScheduledForDeletion !== null) {
- if (!$this->attributesScheduledForDeletion->isEmpty()) {
- AttributeQuery::create()
- ->filterByPrimaryKeys($this->attributesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->attributesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleAttribute !== null) {
- if (!$this->singleAttribute->isDeleted()) {
- $affectedRows += $this->singleAttribute->save($con);
- }
- }
-
- if ($this->attributeAvsScheduledForDeletion !== null) {
- if (!$this->attributeAvsScheduledForDeletion->isEmpty()) {
- AttributeAvQuery::create()
- ->filterByPrimaryKeys($this->attributeAvsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->attributeAvsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleAttributeAv !== null) {
- if (!$this->singleAttributeAv->isDeleted()) {
- $affectedRows += $this->singleAttributeAv->save($con);
- }
- }
-
- if ($this->combinationsScheduledForDeletion !== null) {
- if (!$this->combinationsScheduledForDeletion->isEmpty()) {
- CombinationQuery::create()
- ->filterByPrimaryKeys($this->combinationsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->combinationsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCombination !== null) {
- if (!$this->singleCombination->isDeleted()) {
- $affectedRows += $this->singleCombination->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -830,29 +809,35 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttribute !== null) {
+ if (!$this->aAttribute->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aAttribute->getValidationFailures());
+ }
+ }
+
+ if ($this->aAttributeAv !== null) {
+ if (!$this->aAttributeAv->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aAttributeAv->getValidationFailures());
+ }
+ }
+
+ if ($this->aCombination !== null) {
+ if (!$this->aCombination->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCombination->getValidationFailures());
+ }
+ }
+
+
if (($retval = AttributeCombinationPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleAttribute !== null) {
- if (!$this->singleAttribute->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleAttribute->getValidationFailures());
- }
- }
-
- if ($this->singleAttributeAv !== null) {
- if (!$this->singleAttributeAv->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleAttributeAv->getValidationFailures());
- }
- }
-
- if ($this->singleCombination !== null) {
- if (!$this->singleCombination->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCombination->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -943,14 +928,14 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
$keys[5] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleAttribute) {
- $result['Attribute'] = $this->singleAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleAttributeAv) {
- $result['AttributeAv'] = $this->singleAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aAttributeAv) {
+ $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleCombination) {
- $result['Combination'] = $this->singleCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCombination) {
+ $result['Combination'] = $this->aCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1140,21 +1125,6 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAttribute();
- if ($relObj) {
- $copyObj->setAttribute($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getAttributeAv();
- if ($relObj) {
- $copyObj->setAttributeAv($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getCombination();
- if ($relObj) {
- $copyObj->setCombination($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1205,127 +1175,159 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Attribute object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Attribute object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Attribute
- * @throws PropelException
- */
- public function getAttribute(PropelPDO $con = null)
- {
-
- if ($this->singleAttribute === null && !$this->isNew()) {
- $this->singleAttribute = AttributeQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleAttribute;
- }
-
- /**
- * Sets a single Attribute object as related to this object by a one-to-one relationship.
- *
- * @param Attribute $v Attribute
+ * @param Attribute $v
* @return AttributeCombination The current object (for fluent API support)
* @throws PropelException
*/
public function setAttribute(Attribute $v = null)
{
- $this->singleAttribute = $v;
-
- // Make sure that that the passed-in Attribute isn't already associated with this object
- if ($v !== null && $v->getAttributeCombination() === null) {
- $v->setAttributeCombination($this);
+ if ($v === null) {
+ $this->setAttributeId(NULL);
+ } else {
+ $this->setAttributeId($v->getId());
}
+ $this->aAttribute = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Attribute object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCombination($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single AttributeAv object, which is related to this object by a one-to-one relationship.
+ * Get the associated Attribute object
*
- * @param PropelPDO $con optional connection object
- * @return AttributeAv
+ * @param PropelPDO $con Optional Connection object.
+ * @return Attribute The associated Attribute object.
* @throws PropelException
*/
- public function getAttributeAv(PropelPDO $con = null)
+ public function getAttribute(PropelPDO $con = null)
{
-
- if ($this->singleAttributeAv === null && !$this->isNew()) {
- $this->singleAttributeAv = AttributeAvQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aAttribute === null && ($this->attribute_id !== null)) {
+ $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_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->aAttribute->addAttributeCombinations($this);
+ */
}
- return $this->singleAttributeAv;
+ return $this->aAttribute;
}
/**
- * Sets a single AttributeAv object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a AttributeAv object.
*
- * @param AttributeAv $v AttributeAv
+ * @param AttributeAv $v
* @return AttributeCombination The current object (for fluent API support)
* @throws PropelException
*/
public function setAttributeAv(AttributeAv $v = null)
{
- $this->singleAttributeAv = $v;
-
- // Make sure that that the passed-in AttributeAv isn't already associated with this object
- if ($v !== null && $v->getAttributeCombination() === null) {
- $v->setAttributeCombination($this);
+ if ($v === null) {
+ $this->setAttributeAvId(NULL);
+ } else {
+ $this->setAttributeAvId($v->getId());
}
+ $this->aAttributeAv = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the AttributeAv object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCombination($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Combination object, which is related to this object by a one-to-one relationship.
+ * Get the associated AttributeAv object
*
- * @param PropelPDO $con optional connection object
- * @return Combination
+ * @param PropelPDO $con Optional Connection object.
+ * @return AttributeAv The associated AttributeAv object.
* @throws PropelException
*/
- public function getCombination(PropelPDO $con = null)
+ public function getAttributeAv(PropelPDO $con = null)
{
-
- if ($this->singleCombination === null && !$this->isNew()) {
- $this->singleCombination = CombinationQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aAttributeAv === null && ($this->attribute_av_id !== null)) {
+ $this->aAttributeAv = AttributeAvQuery::create()->findPk($this->attribute_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->aAttributeAv->addAttributeCombinations($this);
+ */
}
- return $this->singleCombination;
+ return $this->aAttributeAv;
}
/**
- * Sets a single Combination object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Combination object.
*
- * @param Combination $v Combination
+ * @param Combination $v
* @return AttributeCombination The current object (for fluent API support)
* @throws PropelException
*/
public function setCombination(Combination $v = null)
{
- $this->singleCombination = $v;
-
- // Make sure that that the passed-in Combination isn't already associated with this object
- if ($v !== null && $v->getAttributeCombination() === null) {
- $v->setAttributeCombination($this);
+ if ($v === null) {
+ $this->setCombinationId(NULL);
+ } else {
+ $this->setCombinationId($v->getId());
}
+ $this->aCombination = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Combination object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCombination($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Combination object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Combination The associated Combination object.
+ * @throws PropelException
+ */
+ public function getCombination(PropelPDO $con = null)
+ {
+ if ($this->aCombination === null && ($this->combination_id !== null)) {
+ $this->aCombination = CombinationQuery::create()->findPk($this->combination_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->aCombination->addAttributeCombinations($this);
+ */
+ }
+
+ return $this->aCombination;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1357,29 +1359,11 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleAttribute) {
- $this->singleAttribute->clearAllReferences($deep);
- }
- if ($this->singleAttributeAv) {
- $this->singleAttributeAv->clearAllReferences($deep);
- }
- if ($this->singleCombination) {
- $this->singleCombination->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleAttribute instanceof PropelCollection) {
- $this->singleAttribute->clearIterator();
- }
- $this->singleAttribute = null;
- if ($this->singleAttributeAv instanceof PropelCollection) {
- $this->singleAttributeAv->clearIterator();
- }
- $this->singleAttributeAv = null;
- if ($this->singleCombination instanceof PropelCollection) {
- $this->singleCombination->clearIterator();
- }
- $this->singleCombination = null;
+ $this->aAttribute = null;
+ $this->aAttributeAv = null;
+ $this->aCombination = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php
index 91c6d31c9..49bb8677d 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php
@@ -27,7 +27,7 @@ abstract class BaseAttributeCombinationPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'attribute_combination';
@@ -390,15 +390,6 @@ abstract class BaseAttributeCombinationPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in AttributePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- AttributePeer::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 CombinationPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CombinationPeer::clearInstancePool();
}
/**
@@ -495,6 +486,983 @@ abstract class BaseAttributeCombinationPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Attribute table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAttribute(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related AttributeAv table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAttributeAv(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Combination table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCombination(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCombination objects pre-filled with their Attribute objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCombination objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+ }
+
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ $startcol = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
+ AttributePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AttributeCombinationPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCombinationPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ AttributePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AttributeCombination) to $obj2 (Attribute)
+ $obj2->addAttributeCombination($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCombination objects pre-filled with their AttributeAv objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCombination objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAttributeAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+ }
+
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ $startcol = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
+ AttributeAvPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AttributeCombinationPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCombinationPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributeAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ AttributeAvPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AttributeCombination) to $obj2 (AttributeAv)
+ $obj2->addAttributeCombination($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCombination objects pre-filled with their Combination objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCombination objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+ }
+
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ $startcol = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
+ CombinationPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AttributeCombinationPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCombinationPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CombinationPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CombinationPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CombinationPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AttributeCombination) to $obj2 (Combination)
+ $obj2->addAttributeCombination($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of AttributeCombination objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCombination objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+ }
+
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS;
+
+ AttributeAvPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
+
+ CombinationPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + CombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeCombinationPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCombinationPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Attribute rows
+
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AttributePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj2 (Attribute)
+ $obj2->addAttributeCombination($obj1);
+ } // if joined row not null
+
+ // Add objects for joined AttributeAv rows
+
+ $key3 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = AttributeAvPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = AttributeAvPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ AttributeAvPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj3 (AttributeAv)
+ $obj3->addAttributeCombination($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Combination rows
+
+ $key4 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = CombinationPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = CombinationPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ CombinationPeer::addInstanceToPool($obj4, $key4);
+ } // if obj4 loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj4 (Combination)
+ $obj4->addAttributeCombination($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Attribute table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptAttribute(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related AttributeAv table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptAttributeAv(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Combination table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCombination(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCombination objects pre-filled with all related objects except Attribute.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCombination objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+ }
+
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributeAvPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
+
+ CombinationPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeCombinationPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCombinationPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined AttributeAv rows
+
+ $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributeAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AttributeAvPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj2 (AttributeAv)
+ $obj2->addAttributeCombination($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Combination rows
+
+ $key3 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CombinationPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CombinationPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CombinationPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj3 (Combination)
+ $obj3->addAttributeCombination($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCombination objects pre-filled with all related objects except AttributeAv.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCombination objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptAttributeAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+ }
+
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS;
+
+ CombinationPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeCombinationPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCombinationPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Attribute rows
+
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AttributePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj2 (Attribute)
+ $obj2->addAttributeCombination($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Combination rows
+
+ $key3 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CombinationPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CombinationPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CombinationPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj3 (Combination)
+ $obj3->addAttributeCombination($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of AttributeCombination objects pre-filled with all related objects except Combination.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeCombination objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+ }
+
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS;
+
+ AttributeAvPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeCombinationPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeCombinationPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Attribute rows
+
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AttributePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj2 (Attribute)
+ $obj2->addAttributeCombination($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined AttributeAv rows
+
+ $key3 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = AttributeAvPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = AttributeAvPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ AttributeAvPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (AttributeCombination) to the collection in $obj3 (AttributeAv)
+ $obj3->addAttributeCombination($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -652,7 +1620,6 @@ abstract class BaseAttributeCombinationPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += AttributeCombinationPeer::doOnDeleteCascade(new Criteria(AttributeCombinationPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(AttributeCombinationPeer::TABLE_NAME, $con, AttributeCombinationPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -686,9 +1653,15 @@ abstract class BaseAttributeCombinationPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ AttributeCombinationPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof AttributeCombination) { // it's a model object
+ // invalidate the cache for this single object
+ AttributeCombinationPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
@@ -705,6 +1678,8 @@ abstract class BaseAttributeCombinationPeer
$criterion->addAnd($criteria->getNewCriterion(AttributeCombinationPeer::COMBINATION_ID, $value[2]));
$criterion->addAnd($criteria->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $value[3]));
$criteria->addOr($criterion);
+ // we can invalidate the cache for this single PK
+ AttributeCombinationPeer::removeInstanceFromPool($value);
}
}
@@ -718,23 +1693,6 @@ abstract class BaseAttributeCombinationPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += AttributeCombinationPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- AttributeCombinationPeer::clearInstancePool();
- } elseif ($values instanceof AttributeCombination) { // it's a model object
- AttributeCombinationPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- AttributeCombinationPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
AttributeCombinationPeer::clearRelatedInstancePool();
$con->commit();
@@ -746,51 +1704,6 @@ abstract class BaseAttributeCombinationPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = AttributeCombinationPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Attribute objects
- $criteria = new Criteria(AttributePeer::DATABASE_NAME);
-
- $criteria->add(AttributePeer::ID, $obj->getAttributeId());
- $affectedRows += AttributePeer::doDelete($criteria, $con);
-
- // delete related AttributeAv objects
- $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME);
-
- $criteria->add(AttributeAvPeer::ID, $obj->getAttributeAvId());
- $affectedRows += AttributeAvPeer::doDelete($criteria, $con);
-
- // delete related Combination objects
- $criteria = new Criteria(CombinationPeer::DATABASE_NAME);
-
- $criteria->add(CombinationPeer::ID, $obj->getCombinationId());
- $affectedRows += CombinationPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given AttributeCombination object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php
index 0c51905a8..2d6edd41d 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php
@@ -82,7 +82,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\AttributeCombination', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\AttributeCombination', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -306,6 +306,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
* $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
*
*
+ * @see filterByAttribute()
+ *
* @param mixed $attributeId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -333,6 +335,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
* $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12
*
*
+ * @see filterByCombination()
+ *
* @param mixed $combinationId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -360,6 +364,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
* $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id > 12
*
*
+ * @see filterByAttributeAv()
+ *
* @param mixed $attributeAvId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -466,7 +472,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
/**
* Filter the query by a related Attribute object
*
- * @param Attribute|PropelObjectCollection $attribute the related object to use as filter
+ * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeCombinationQuery The current query, for fluid interface
@@ -478,10 +484,12 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
return $this
->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison);
} elseif ($attribute instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useAttributeQuery()
- ->filterByPrimaryKeys($attribute->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection');
}
@@ -540,7 +548,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
/**
* Filter the query by a related AttributeAv object
*
- * @param AttributeAv|PropelObjectCollection $attributeAv the related object to use as filter
+ * @param AttributeAv|PropelObjectCollection $attributeAv The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeCombinationQuery The current query, for fluid interface
@@ -552,10 +560,12 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
return $this
->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison);
} elseif ($attributeAv instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useAttributeAvQuery()
- ->filterByPrimaryKeys($attributeAv->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection');
}
@@ -614,7 +624,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
/**
* Filter the query by a related Combination object
*
- * @param Combination|PropelObjectCollection $combination the related object to use as filter
+ * @param Combination|PropelObjectCollection $combination The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeCombinationQuery The current query, for fluid interface
@@ -626,10 +636,12 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria
return $this
->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combination->getId(), $comparison);
} elseif ($combination instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCombinationQuery()
- ->filterByPrimaryKeys($combination->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCombination() only accepts arguments of type Combination or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeDesc.php b/core/lib/Thelia/Model/om/BaseAttributeDesc.php
index 04a892bfe..9f0247632 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeDesc.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Attribute;
use Thelia\Model\AttributeDesc;
@@ -98,9 +96,9 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Attribute one-to-one related Attribute object
+ * @var Attribute
*/
- protected $singleAttribute;
+ protected $aAttribute;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $attributesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -315,6 +307,10 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = AttributeDescPeer::ATTRIBUTE_ID;
}
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
return $this;
} // setAttributeId()
@@ -499,6 +495,9 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
} // ensureConsistency
/**
@@ -538,8 +537,7 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleAttribute = null;
-
+ $this->aAttribute = null;
} // if (deep)
}
@@ -653,6 +651,18 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttribute !== null) {
+ if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) {
+ $affectedRows += $this->aAttribute->save($con);
+ }
+ $this->setAttribute($this->aAttribute);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -664,21 +674,6 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->attributesScheduledForDeletion !== null) {
- if (!$this->attributesScheduledForDeletion->isEmpty()) {
- AttributeQuery::create()
- ->filterByPrimaryKeys($this->attributesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->attributesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleAttribute !== null) {
- if (!$this->singleAttribute->isDeleted()) {
- $affectedRows += $this->singleAttribute->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -858,17 +853,23 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttribute !== null) {
+ if (!$this->aAttribute->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aAttribute->getValidationFailures());
+ }
+ }
+
+
if (($retval = AttributeDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleAttribute !== null) {
- if (!$this->singleAttribute->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleAttribute->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -967,8 +968,8 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleAttribute) {
- $result['Attribute'] = $this->singleAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1157,11 +1158,6 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAttribute();
- if ($relObj) {
- $copyObj->setAttribute($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1212,55 +1208,57 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Attribute object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Attribute object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Attribute
- * @throws PropelException
- */
- public function getAttribute(PropelPDO $con = null)
- {
-
- if ($this->singleAttribute === null && !$this->isNew()) {
- $this->singleAttribute = AttributeQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleAttribute;
- }
-
- /**
- * Sets a single Attribute object as related to this object by a one-to-one relationship.
- *
- * @param Attribute $v Attribute
+ * @param Attribute $v
* @return AttributeDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setAttribute(Attribute $v = null)
{
- $this->singleAttribute = $v;
-
- // Make sure that that the passed-in Attribute isn't already associated with this object
- if ($v !== null && $v->getAttributeDesc() === null) {
- $v->setAttributeDesc($this);
+ if ($v === null) {
+ $this->setAttributeId(NULL);
+ } else {
+ $this->setAttributeId($v->getId());
}
+ $this->aAttribute = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Attribute object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Attribute object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Attribute The associated Attribute object.
+ * @throws PropelException
+ */
+ public function getAttribute(PropelPDO $con = null)
+ {
+ if ($this->aAttribute === null && ($this->attribute_id !== null)) {
+ $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_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->aAttribute->addAttributeDescs($this);
+ */
+ }
+
+ return $this->aAttribute;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1294,15 +1292,9 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleAttribute) {
- $this->singleAttribute->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleAttribute instanceof PropelCollection) {
- $this->singleAttribute->clearIterator();
- }
- $this->singleAttribute = null;
+ $this->aAttribute = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseAttributeDescPeer.php b/core/lib/Thelia/Model/om/BaseAttributeDescPeer.php
index 7699e8dd4..4dd4dd57d 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseAttributeDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'attribute_desc';
@@ -398,9 +398,6 @@ abstract class BaseAttributeDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in AttributePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- AttributePeer::clearInstancePool();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseAttributeDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Attribute table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAttribute(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeDescPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of AttributeDesc objects pre-filled with their Attribute objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME);
+ }
+
+ AttributeDescPeer::addSelectColumns($criteria);
+ $startcol = AttributeDescPeer::NUM_HYDRATE_COLUMNS;
+ AttributePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AttributeDescPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = AttributeDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ AttributePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (AttributeDesc) to $obj2 (Attribute)
+ $obj2->addAttributeDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AttributeDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AttributeDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(AttributeDescPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of AttributeDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of AttributeDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME);
+ }
+
+ AttributeDescPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeDescPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeDescPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = AttributeDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = AttributeDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = AttributeDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ AttributeDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Attribute rows
+
+ $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AttributePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AttributePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AttributePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (AttributeDesc) to the collection in $obj2 (Attribute)
+ $obj2->addAttributeDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -630,7 +865,6 @@ abstract class BaseAttributeDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += AttributeDescPeer::doOnDeleteCascade(new Criteria(AttributeDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(AttributeDescPeer::TABLE_NAME, $con, AttributeDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +898,24 @@ abstract class BaseAttributeDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ AttributeDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof AttributeDesc) { // it's a model object
+ // invalidate the cache for this single object
+ AttributeDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AttributeDescPeer::DATABASE_NAME);
$criteria->add(AttributeDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AttributeDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,23 +928,6 @@ abstract class BaseAttributeDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += AttributeDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- AttributeDescPeer::clearInstancePool();
- } elseif ($values instanceof AttributeDesc) { // it's a model object
- AttributeDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- AttributeDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
AttributeDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -712,39 +939,6 @@ abstract class BaseAttributeDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = AttributeDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Attribute objects
- $criteria = new Criteria(AttributePeer::DATABASE_NAME);
-
- $criteria->add(AttributePeer::ID, $obj->getAttributeId());
- $affectedRows += AttributePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given AttributeDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php b/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php
index b5eee77f4..421f6279c 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseAttributeDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\AttributeDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\AttributeDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -312,6 +312,8 @@ abstract class BaseAttributeDescQuery extends ModelCriteria
* $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
*
*
+ * @see filterByAttribute()
+ *
* @param mixed $attributeId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +521,7 @@ abstract class BaseAttributeDescQuery extends ModelCriteria
/**
* Filter the query by a related Attribute object
*
- * @param Attribute|PropelObjectCollection $attribute the related object to use as filter
+ * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeDescQuery The current query, for fluid interface
@@ -531,10 +533,12 @@ abstract class BaseAttributeDescQuery extends ModelCriteria
return $this
->addUsingAlias(AttributeDescPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison);
} elseif ($attribute instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useAttributeQuery()
- ->filterByPrimaryKeys($attribute->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(AttributeDescPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseAttributePeer.php b/core/lib/Thelia/Model/om/BaseAttributePeer.php
index 5f699f244..33e211dc0 100644
--- a/core/lib/Thelia/Model/om/BaseAttributePeer.php
+++ b/core/lib/Thelia/Model/om/BaseAttributePeer.php
@@ -28,7 +28,7 @@ abstract class BaseAttributePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'attribute';
@@ -381,6 +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();
}
/**
@@ -477,1385 +489,6 @@ abstract class BaseAttributePeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeAv table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAttributeAv(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAttributeCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCombination table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAttributeCombination(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAttributeDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Attribute objects pre-filled with their AttributeAv objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAttributeAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol = AttributePeer::NUM_HYDRATE_COLUMNS;
- AttributeAvPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AttributeAvPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Attribute) to $obj2 (AttributeAv)
- // one to one relationship
- $obj1->setAttributeAv($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Attribute objects pre-filled with their AttributeCategory objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAttributeCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol = AttributePeer::NUM_HYDRATE_COLUMNS;
- AttributeCategoryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Attribute) to $obj2 (AttributeCategory)
- // one to one relationship
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Attribute objects pre-filled with their AttributeCombination objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAttributeCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol = AttributePeer::NUM_HYDRATE_COLUMNS;
- AttributeCombinationPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AttributeCombinationPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AttributeCombinationPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Attribute) to $obj2 (AttributeCombination)
- // one to one relationship
- $obj1->setAttributeCombination($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Attribute objects pre-filled with their AttributeDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAttributeDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol = AttributePeer::NUM_HYDRATE_COLUMNS;
- AttributeDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AttributeDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AttributeDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AttributeDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Attribute) to $obj2 (AttributeDesc)
- // one to one relationship
- $obj1->setAttributeDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Attribute objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol2 = AttributePeer::NUM_HYDRATE_COLUMNS;
-
- AttributeAvPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCombinationPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeDescPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + AttributeDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeAv rows
-
- $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeAvPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj2 (AttributeAv)
- $obj1->setAttributeAv($obj2);
- } // if joined row not null
-
- // Add objects for joined AttributeCategory rows
-
- $key3 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AttributeCategoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AttributeCategoryPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj3 (AttributeCategory)
- $obj1->setAttributeCategory($obj3);
- } // if joined row not null
-
- // Add objects for joined AttributeCombination rows
-
- $key4 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = AttributeCombinationPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- AttributeCombinationPeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj4 (AttributeCombination)
- $obj1->setAttributeCombination($obj4);
- } // if joined row not null
-
- // Add objects for joined AttributeDesc rows
-
- $key5 = AttributeDescPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = AttributeDescPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = AttributeDescPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- AttributeDescPeer::addInstanceToPool($obj5, $key5);
- } // if obj5 loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj5 (AttributeDesc)
- $obj1->setAttributeDesc($obj5);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeAv table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAttributeAv(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAttributeCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCombination table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAttributeCombination(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAttributeDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- AttributePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Attribute objects pre-filled with all related objects except AttributeAv.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAttributeAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol2 = AttributePeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCombinationPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + AttributeDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined AttributeCombination rows
-
- $key3 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AttributeCombinationPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AttributeCombinationPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj3 (AttributeCombination)
- $obj1->setAttributeCombination($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined AttributeDesc rows
-
- $key4 = AttributeDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = AttributeDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = AttributeDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- AttributeDescPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj4 (AttributeDesc)
- $obj1->setAttributeDesc($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Attribute objects pre-filled with all related objects except AttributeCategory.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAttributeCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol2 = AttributePeer::NUM_HYDRATE_COLUMNS;
-
- AttributeAvPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCombinationPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + AttributeDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeAv rows
-
- $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeAvPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj2 (AttributeAv)
- $obj1->setAttributeAv($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined AttributeCombination rows
-
- $key3 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AttributeCombinationPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AttributeCombinationPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj3 (AttributeCombination)
- $obj1->setAttributeCombination($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined AttributeDesc rows
-
- $key4 = AttributeDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = AttributeDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = AttributeDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- AttributeDescPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj4 (AttributeDesc)
- $obj1->setAttributeDesc($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Attribute objects pre-filled with all related objects except AttributeCombination.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAttributeCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol2 = AttributePeer::NUM_HYDRATE_COLUMNS;
-
- AttributeAvPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + AttributeDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeDescPeer::ATTRIBUTE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeAv rows
-
- $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeAvPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj2 (AttributeAv)
- $obj1->setAttributeAv($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined AttributeCategory rows
-
- $key3 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AttributeCategoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AttributeCategoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj3 (AttributeCategory)
- $obj1->setAttributeCategory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined AttributeDesc rows
-
- $key4 = AttributeDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = AttributeDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = AttributeDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- AttributeDescPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj4 (AttributeDesc)
- $obj1->setAttributeDesc($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Attribute objects pre-filled with all related objects except AttributeDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Attribute objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAttributeDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(AttributePeer::DATABASE_NAME);
- }
-
- AttributePeer::addSelectColumns($criteria);
- $startcol2 = AttributePeer::NUM_HYDRATE_COLUMNS;
-
- AttributeAvPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCombinationPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(AttributePeer::ID, AttributeAvPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCategoryPeer::ATTRIBUTE_ID, $join_behavior);
-
- $criteria->addJoin(AttributePeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = AttributePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = AttributePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- AttributePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeAv rows
-
- $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeAvPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj2 (AttributeAv)
- $obj1->setAttributeAv($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined AttributeCategory rows
-
- $key3 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AttributeCategoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AttributeCategoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj3 (AttributeCategory)
- $obj1->setAttributeCategory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined AttributeCombination rows
-
- $key4 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = AttributeCombinationPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- AttributeCombinationPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Attribute) to the collection in $obj4 (AttributeCombination)
- $obj1->setAttributeCombination($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseAttributeQuery.php b/core/lib/Thelia/Model/om/BaseAttributeQuery.php
index b96751b74..15ca7f633 100644
--- a/core/lib/Thelia/Model/om/BaseAttributeQuery.php
+++ b/core/lib/Thelia/Model/om/BaseAttributeQuery.php
@@ -79,7 +79,7 @@ abstract class BaseAttributeQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Attribute', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Attribute', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -255,14 +255,6 @@ abstract class BaseAttributeQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAttributeAv()
- *
- * @see filterByAttributeCategory()
- *
- * @see filterByAttributeCombination()
- *
- * @see filterByAttributeDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -410,7 +402,7 @@ abstract class BaseAttributeQuery extends ModelCriteria
/**
* Filter the query by a related AttributeAv object
*
- * @param AttributeAv|PropelObjectCollection $attributeAv The related object(s) to use as filter
+ * @param AttributeAv|PropelObjectCollection $attributeAv the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeQuery The current query, for fluid interface
@@ -422,12 +414,10 @@ abstract class BaseAttributeQuery extends ModelCriteria
return $this
->addUsingAlias(AttributePeer::ID, $attributeAv->getAttributeId(), $comparison);
} elseif ($attributeAv instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AttributePeer::ID, $attributeAv->toKeyValue('PrimaryKey', 'AttributeId'), $comparison);
+ ->useAttributeAvQuery()
+ ->filterByPrimaryKeys($attributeAv->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection');
}
@@ -486,7 +476,7 @@ abstract class BaseAttributeQuery extends ModelCriteria
/**
* Filter the query by a related AttributeCategory object
*
- * @param AttributeCategory|PropelObjectCollection $attributeCategory The related object(s) 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
@@ -498,12 +488,10 @@ abstract class BaseAttributeQuery extends ModelCriteria
return $this
->addUsingAlias(AttributePeer::ID, $attributeCategory->getAttributeId(), $comparison);
} elseif ($attributeCategory instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AttributePeer::ID, $attributeCategory->toKeyValue('PrimaryKey', 'AttributeId'), $comparison);
+ ->useAttributeCategoryQuery()
+ ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection');
}
@@ -562,7 +550,7 @@ abstract class BaseAttributeQuery extends ModelCriteria
/**
* Filter the query by a related AttributeCombination object
*
- * @param AttributeCombination|PropelObjectCollection $attributeCombination The related object(s) to use as filter
+ * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return AttributeQuery The current query, for fluid interface
@@ -574,12 +562,10 @@ abstract class BaseAttributeQuery extends ModelCriteria
return $this
->addUsingAlias(AttributePeer::ID, $attributeCombination->getAttributeId(), $comparison);
} elseif ($attributeCombination instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AttributePeer::ID, $attributeCombination->toKeyValue('AttributeId', 'AttributeId'), $comparison);
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection');
}
@@ -638,7 +624,7 @@ abstract class BaseAttributeQuery extends ModelCriteria
/**
* Filter the query by a related AttributeDesc object
*
- * @param AttributeDesc|PropelObjectCollection $attributeDesc The related object(s) to use as filter
+ * @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
@@ -650,12 +636,10 @@ abstract class BaseAttributeQuery extends ModelCriteria
return $this
->addUsingAlias(AttributePeer::ID, $attributeDesc->getAttributeId(), $comparison);
} elseif ($attributeDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(AttributePeer::ID, $attributeDesc->toKeyValue('PrimaryKey', 'AttributeId'), $comparison);
+ ->useAttributeDescQuery()
+ ->filterByPrimaryKeys($attributeDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAttributeDesc() only accepts arguments of type AttributeDesc or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseCategory.php b/core/lib/Thelia/Model/om/BaseCategory.php
index d840afe56..75729a095 100644
--- a/core/lib/Thelia/Model/om/BaseCategory.php
+++ b/core/lib/Thelia/Model/om/BaseCategory.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\AttributeCategory;
use Thelia\Model\AttributeCategoryQuery;
@@ -104,44 +106,52 @@ abstract class BaseCategory extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var AttributeCategory
+ * @var PropelObjectCollection|AttributeCategory[] Collection to store aggregation of AttributeCategory objects.
*/
- protected $aAttributeCategory;
+ protected $collAttributeCategorys;
+ protected $collAttributeCategorysPartial;
/**
- * @var CategoryDesc
+ * @var PropelObjectCollection|CategoryDesc[] Collection to store aggregation of CategoryDesc objects.
*/
- protected $aCategoryDesc;
+ protected $collCategoryDescs;
+ protected $collCategoryDescsPartial;
/**
- * @var ContentAssoc
+ * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects.
*/
- protected $aContentAssoc;
+ protected $collContentAssocs;
+ protected $collContentAssocsPartial;
/**
- * @var Document
+ * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects.
*/
- protected $aDocument;
+ protected $collDocuments;
+ protected $collDocumentsPartial;
/**
- * @var FeatureCategory
+ * @var PropelObjectCollection|FeatureCategory[] Collection to store aggregation of FeatureCategory objects.
*/
- protected $aFeatureCategory;
+ protected $collFeatureCategorys;
+ protected $collFeatureCategorysPartial;
/**
- * @var Image
+ * @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects.
*/
- protected $aImage;
+ protected $collImages;
+ protected $collImagesPartial;
/**
- * @var ProductCategory
+ * @var PropelObjectCollection|ProductCategory[] Collection to store aggregation of ProductCategory objects.
*/
- protected $aProductCategory;
+ protected $collProductCategorys;
+ protected $collProductCategorysPartial;
/**
- * @var Rewriting
+ * @var PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects.
*/
- protected $aRewriting;
+ protected $collRewritings;
+ protected $collRewritingsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -157,6 +167,54 @@ 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
+ */
+ protected $categoryDescsScheduledForDeletion = 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 $featureCategorysScheduledForDeletion = 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 $rewritingsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -298,38 +356,6 @@ abstract class BaseCategory extends BaseObject implements Persistent
$this->modifiedColumns[] = CategoryPeer::ID;
}
- if ($this->aAttributeCategory !== null && $this->aAttributeCategory->getCategoryId() !== $v) {
- $this->aAttributeCategory = null;
- }
-
- if ($this->aCategoryDesc !== null && $this->aCategoryDesc->getCategoryId() !== $v) {
- $this->aCategoryDesc = null;
- }
-
- if ($this->aContentAssoc !== null && $this->aContentAssoc->getCategoryId() !== $v) {
- $this->aContentAssoc = null;
- }
-
- if ($this->aDocument !== null && $this->aDocument->getCategoryId() !== $v) {
- $this->aDocument = null;
- }
-
- if ($this->aFeatureCategory !== null && $this->aFeatureCategory->getCategoryId() !== $v) {
- $this->aFeatureCategory = null;
- }
-
- if ($this->aImage !== null && $this->aImage->getCategoryId() !== $v) {
- $this->aImage = null;
- }
-
- if ($this->aProductCategory !== null && $this->aProductCategory->getCategoryId() !== $v) {
- $this->aProductCategory = null;
- }
-
- if ($this->aRewriting !== null && $this->aRewriting->getCategoryId() !== $v) {
- $this->aRewriting = null;
- }
-
return $this;
} // setId()
@@ -534,30 +560,6 @@ abstract class BaseCategory extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAttributeCategory !== null && $this->id !== $this->aAttributeCategory->getCategoryId()) {
- $this->aAttributeCategory = null;
- }
- if ($this->aCategoryDesc !== null && $this->id !== $this->aCategoryDesc->getCategoryId()) {
- $this->aCategoryDesc = null;
- }
- if ($this->aContentAssoc !== null && $this->id !== $this->aContentAssoc->getCategoryId()) {
- $this->aContentAssoc = null;
- }
- if ($this->aDocument !== null && $this->id !== $this->aDocument->getCategoryId()) {
- $this->aDocument = null;
- }
- if ($this->aFeatureCategory !== null && $this->id !== $this->aFeatureCategory->getCategoryId()) {
- $this->aFeatureCategory = null;
- }
- if ($this->aImage !== null && $this->id !== $this->aImage->getCategoryId()) {
- $this->aImage = null;
- }
- if ($this->aProductCategory !== null && $this->id !== $this->aProductCategory->getCategoryId()) {
- $this->aProductCategory = null;
- }
- if ($this->aRewriting !== null && $this->id !== $this->aRewriting->getCategoryId()) {
- $this->aRewriting = null;
- }
} // ensureConsistency
/**
@@ -597,14 +599,22 @@ abstract class BaseCategory extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAttributeCategory = null;
- $this->aCategoryDesc = null;
- $this->aContentAssoc = null;
- $this->aDocument = null;
- $this->aFeatureCategory = null;
- $this->aImage = null;
- $this->aProductCategory = null;
- $this->aRewriting = null;
+ $this->collAttributeCategorys = null;
+
+ $this->collCategoryDescs = null;
+
+ $this->collContentAssocs = null;
+
+ $this->collDocuments = null;
+
+ $this->collFeatureCategorys = null;
+
+ $this->collImages = null;
+
+ $this->collProductCategorys = null;
+
+ $this->collRewritings = null;
+
} // if (deep)
}
@@ -718,67 +728,6 @@ abstract class BaseCategory extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAttributeCategory !== null) {
- if ($this->aAttributeCategory->isModified() || $this->aAttributeCategory->isNew()) {
- $affectedRows += $this->aAttributeCategory->save($con);
- }
- $this->setAttributeCategory($this->aAttributeCategory);
- }
-
- if ($this->aCategoryDesc !== null) {
- if ($this->aCategoryDesc->isModified() || $this->aCategoryDesc->isNew()) {
- $affectedRows += $this->aCategoryDesc->save($con);
- }
- $this->setCategoryDesc($this->aCategoryDesc);
- }
-
- if ($this->aContentAssoc !== null) {
- if ($this->aContentAssoc->isModified() || $this->aContentAssoc->isNew()) {
- $affectedRows += $this->aContentAssoc->save($con);
- }
- $this->setContentAssoc($this->aContentAssoc);
- }
-
- if ($this->aDocument !== null) {
- if ($this->aDocument->isModified() || $this->aDocument->isNew()) {
- $affectedRows += $this->aDocument->save($con);
- }
- $this->setDocument($this->aDocument);
- }
-
- if ($this->aFeatureCategory !== null) {
- if ($this->aFeatureCategory->isModified() || $this->aFeatureCategory->isNew()) {
- $affectedRows += $this->aFeatureCategory->save($con);
- }
- $this->setFeatureCategory($this->aFeatureCategory);
- }
-
- if ($this->aImage !== null) {
- if ($this->aImage->isModified() || $this->aImage->isNew()) {
- $affectedRows += $this->aImage->save($con);
- }
- $this->setImage($this->aImage);
- }
-
- if ($this->aProductCategory !== null) {
- if ($this->aProductCategory->isModified() || $this->aProductCategory->isNew()) {
- $affectedRows += $this->aProductCategory->save($con);
- }
- $this->setProductCategory($this->aProductCategory);
- }
-
- if ($this->aRewriting !== null) {
- if ($this->aRewriting->isModified() || $this->aRewriting->isNew()) {
- $affectedRows += $this->aRewriting->save($con);
- }
- $this->setRewriting($this->aRewriting);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -790,6 +739,146 @@ 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()
+ ->filterByPrimaryKeys($this->categoryDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->categoryDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCategoryDescs !== null) {
+ foreach ($this->collCategoryDescs 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->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) {
+ // 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->rewritingsScheduledForDeletion !== null) {
+ if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
+ foreach ($this->rewritingsScheduledForDeletion as $rewriting) {
+ // need to save related object because we set the relation to null
+ $rewriting->save($con);
+ }
+ $this->rewritingsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -963,65 +1052,75 @@ abstract class BaseCategory extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAttributeCategory !== null) {
- if (!$this->aAttributeCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAttributeCategory->getValidationFailures());
- }
- }
-
- if ($this->aCategoryDesc !== null) {
- if (!$this->aCategoryDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aCategoryDesc->getValidationFailures());
- }
- }
-
- if ($this->aContentAssoc !== null) {
- if (!$this->aContentAssoc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aContentAssoc->getValidationFailures());
- }
- }
-
- if ($this->aDocument !== null) {
- if (!$this->aDocument->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aDocument->getValidationFailures());
- }
- }
-
- if ($this->aFeatureCategory !== null) {
- if (!$this->aFeatureCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aFeatureCategory->getValidationFailures());
- }
- }
-
- if ($this->aImage !== null) {
- if (!$this->aImage->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aImage->getValidationFailures());
- }
- }
-
- if ($this->aProductCategory !== null) {
- if (!$this->aProductCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aProductCategory->getValidationFailures());
- }
- }
-
- if ($this->aRewriting !== null) {
- if (!$this->aRewriting->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aRewriting->getValidationFailures());
- }
- }
-
-
if (($retval = CategoryPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ 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)) {
+ $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->collDocuments !== null) {
+ foreach ($this->collDocuments 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->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->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1116,29 +1215,29 @@ abstract class BaseCategory extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAttributeCategory) {
- $result['AttributeCategory'] = $this->aAttributeCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAttributeCategorys) {
+ $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aCategoryDesc) {
- $result['CategoryDesc'] = $this->aCategoryDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collCategoryDescs) {
+ $result['CategoryDescs'] = $this->collCategoryDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aContentAssoc) {
- $result['ContentAssoc'] = $this->aContentAssoc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aDocument) {
- $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aFeatureCategory) {
- $result['FeatureCategory'] = $this->aFeatureCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFeatureCategorys) {
+ $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aImage) {
- $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aProductCategory) {
- $result['ProductCategory'] = $this->aProductCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collProductCategorys) {
+ $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aRewriting) {
- $result['Rewriting'] = $this->aRewriting->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1321,44 +1420,52 @@ abstract class BaseCategory extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAttributeCategory();
- if ($relObj) {
- $copyObj->setAttributeCategory($relObj->copy($deepCopy));
+ 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));
+ }
}
- $relObj = $this->getCategoryDesc();
- if ($relObj) {
- $copyObj->setCategoryDesc($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));
+ }
}
- $relObj = $this->getContentAssoc();
- if ($relObj) {
- $copyObj->setContentAssoc($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));
+ }
}
- $relObj = $this->getDocument();
- if ($relObj) {
- $copyObj->setDocument($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));
+ }
}
- $relObj = $this->getFeatureCategory();
- if ($relObj) {
- $copyObj->setFeatureCategory($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));
+ }
}
- $relObj = $this->getImage();
- if ($relObj) {
- $copyObj->setImage($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));
+ }
}
- $relObj = $this->getProductCategory();
- if ($relObj) {
- $copyObj->setProductCategory($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));
+ }
}
- $relObj = $this->getRewriting();
- if ($relObj) {
- $copyObj->setRewriting($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));
+ }
}
//unflag object copy
@@ -1411,380 +1518,2047 @@ abstract class BaseCategory extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a AttributeCategory object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param AttributeCategory $v
- * @return Category The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ 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 ('Rewriting' == $relationName) {
+ $this->initRewritings();
+ }
+ }
+
+ /**
+ * 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 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|AttributeCategory[] List of AttributeCategory objects
* @throws PropelException
*/
- public function setAttributeCategory(AttributeCategory $v = null)
+ public function getAttributeCategorys($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByCategory($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->setCategory(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
+ ->filterByCategory($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCategoryId());
+ return count($this->collAttributeCategorys);
}
+ }
- $this->aAttributeCategory = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCategory($this);
+ /**
+ * Method called to associate a AttributeCategory object to this object
+ * through the AttributeCategory foreign key attribute.
+ *
+ * @param AttributeCategory $l AttributeCategory
+ * @return Category 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;
}
-
/**
- * Get the associated AttributeCategory object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AttributeCategory The associated AttributeCategory object.
- * @throws PropelException
+ * @param AttributeCategory $attributeCategory The attributeCategory object to add.
*/
- public function getAttributeCategory(PropelPDO $con = null)
+ protected function doAddAttributeCategory($attributeCategory)
{
- if ($this->aAttributeCategory === null && ($this->id !== null)) {
- $this->aAttributeCategory = AttributeCategoryQuery::create()
- ->filterByCategory($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAttributeCategory->setCategory($this);
- }
-
- return $this->aAttributeCategory;
+ $this->collAttributeCategorys[]= $attributeCategory;
+ $attributeCategory->setCategory($this);
}
/**
- * Declares an association between this object and a CategoryDesc object.
+ * @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->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 AttributeCategorys from storage.
*
- * @param CategoryDesc $v
- * @return Category The current object (for fluent API support)
+ * 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|AttributeCategory[] List of AttributeCategory objects
+ */
+ public function getAttributeCategorysJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AttributeCategoryQuery::create(null, $criteria);
+ $query->joinWith('Attribute', $join_behavior);
+
+ 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 setCategoryDesc(CategoryDesc $v = null)
+ public function getCategoryDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getCategoryId());
+ return count($this->collCategoryDescs);
}
+ }
- $this->aCategoryDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCategory($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated CategoryDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return CategoryDesc The associated CategoryDesc object.
- * @throws PropelException
+ * @param CategoryDesc $categoryDesc The categoryDesc object to add.
*/
- public function getCategoryDesc(PropelPDO $con = null)
+ protected function doAddCategoryDesc($categoryDesc)
{
- if ($this->aCategoryDesc === null && ($this->id !== null)) {
- $this->aCategoryDesc = CategoryDescQuery::create()
- ->filterByCategory($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aCategoryDesc->setCategory($this);
- }
-
- return $this->aCategoryDesc;
+ $this->collCategoryDescs[]= $categoryDesc;
+ $categoryDesc->setCategory($this);
}
/**
- * Declares an association between this object and a ContentAssoc object.
+ * @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
*
- * @param ContentAssoc $v
- * @return Category The current object (for fluent API support)
+ * 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 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|ContentAssoc[] List of ContentAssoc objects
* @throws PropelException
*/
- public function setContentAssoc(ContentAssoc $v = null)
+ public function getContentAssocs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByCategory($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->setCategory(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
+ ->filterByCategory($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCategoryId());
+ return count($this->collContentAssocs);
}
+ }
- $this->aContentAssoc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCategory($this);
+ /**
+ * Method called to associate a ContentAssoc object to this object
+ * through the ContentAssoc foreign key attribute.
+ *
+ * @param ContentAssoc $l ContentAssoc
+ * @return Category 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;
}
-
/**
- * Get the associated ContentAssoc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ContentAssoc The associated ContentAssoc object.
- * @throws PropelException
+ * @param ContentAssoc $contentAssoc The contentAssoc object to add.
*/
- public function getContentAssoc(PropelPDO $con = null)
+ protected function doAddContentAssoc($contentAssoc)
{
- if ($this->aContentAssoc === null && ($this->id !== null)) {
- $this->aContentAssoc = ContentAssocQuery::create()
- ->filterByCategory($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aContentAssoc->setCategory($this);
- }
-
- return $this->aContentAssoc;
+ $this->collContentAssocs[]= $contentAssoc;
+ $contentAssoc->setCategory($this);
}
/**
- * Declares an association between this object and a Document object.
+ * @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->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 ContentAssocs from storage.
*
- * @param Document $v
- * @return Category The current object (for fluent API support)
+ * 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|ContentAssoc[] List of ContentAssoc objects
+ */
+ public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = ContentAssocQuery::create(null, $criteria);
+ $query->joinWith('Product', $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 Category is new, it will return
+ * an empty collection; or if this Category 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 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|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 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 setDocument(Document $v = null)
+ public function getDocuments($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getCategoryId());
+ return count($this->collDocuments);
}
+ }
- $this->aDocument = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCategory($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated Document object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Document The associated Document object.
- * @throws PropelException
+ * @param Document $document The document object to add.
*/
- public function getDocument(PropelPDO $con = null)
+ protected function doAddDocument($document)
{
- if ($this->aDocument === null && ($this->id !== null)) {
- $this->aDocument = DocumentQuery::create()
- ->filterByCategory($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aDocument->setCategory($this);
- }
-
- return $this->aDocument;
+ $this->collDocuments[]= $document;
+ $document->setCategory($this);
}
/**
- * Declares an association between this object and a FeatureCategory object.
+ * @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.
*
- * @param FeatureCategory $v
- * @return Category The current object (for fluent API support)
+ * 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 setFeatureCategory(FeatureCategory $v = null)
+ public function getFeatureCategorys($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getCategoryId());
+ return count($this->collFeatureCategorys);
}
+ }
- $this->aFeatureCategory = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCategory($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated FeatureCategory object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return FeatureCategory The associated FeatureCategory object.
- * @throws PropelException
+ * @param FeatureCategory $featureCategory The featureCategory object to add.
*/
- public function getFeatureCategory(PropelPDO $con = null)
+ protected function doAddFeatureCategory($featureCategory)
{
- if ($this->aFeatureCategory === null && ($this->id !== null)) {
- $this->aFeatureCategory = FeatureCategoryQuery::create()
- ->filterByCategory($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFeatureCategory->setCategory($this);
- }
-
- return $this->aFeatureCategory;
+ $this->collFeatureCategorys[]= $featureCategory;
+ $featureCategory->setCategory($this);
}
/**
- * Declares an association between this object and a Image object.
+ * @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.
*
- * @param Image $v
- * @return Category The current object (for fluent API support)
+ * 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
+ *
+ * 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 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|Image[] List of Image objects
* @throws PropelException
*/
- public function setImage(Image $v = null)
+ public function getImages($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByCategory($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->setCategory(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
+ ->filterByCategory($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCategoryId());
+ return count($this->collImages);
}
+ }
- $this->aImage = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCategory($this);
+ /**
+ * Method called to associate a Image object to this object
+ * through the Image foreign key attribute.
+ *
+ * @param Image $l Image
+ * @return Category 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;
}
-
/**
- * Get the associated Image object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Image The associated Image object.
- * @throws PropelException
+ * @param Image $image The image object to add.
*/
- public function getImage(PropelPDO $con = null)
+ protected function doAddImage($image)
{
- if ($this->aImage === null && ($this->id !== null)) {
- $this->aImage = ImageQuery::create()
- ->filterByCategory($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aImage->setCategory($this);
- }
-
- return $this->aImage;
+ $this->collImages[]= $image;
+ $image->setCategory($this);
}
/**
- * Declares an association between this object and a ProductCategory object.
+ * @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->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 Images from storage.
*
- * @param ProductCategory $v
- * @return Category The current object (for fluent API support)
+ * 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|Image[] List of Image objects
+ */
+ public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = ImageQuery::create(null, $criteria);
+ $query->joinWith('Product', $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 Category is new, it will return
+ * an empty collection; or if this Category 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 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|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 Category is new, it will return
+ * an empty collection; or if this Category 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 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|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 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 setProductCategory(ProductCategory $v = null)
+ public function getProductCategorys($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getCategoryId());
+ return count($this->collProductCategorys);
}
+ }
- $this->aProductCategory = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCategory($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated ProductCategory object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ProductCategory The associated ProductCategory object.
- * @throws PropelException
+ * @param ProductCategory $productCategory The productCategory object to add.
*/
- public function getProductCategory(PropelPDO $con = null)
+ protected function doAddProductCategory($productCategory)
{
- if ($this->aProductCategory === null && ($this->id !== null)) {
- $this->aProductCategory = ProductCategoryQuery::create()
- ->filterByCategory($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aProductCategory->setCategory($this);
- }
-
- return $this->aProductCategory;
+ $this->collProductCategorys[]= $productCategory;
+ $productCategory->setCategory($this);
}
/**
- * Declares an association between this object and a Rewriting object.
+ * @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.
*
- * @param Rewriting $v
- * @return Category The current object (for fluent API support)
+ * 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 collRewritings 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 addRewritings()
+ */
+ public function clearRewritings()
+ {
+ $this->collRewritings = null; // important to set this to null since that means it is uninitialized
+ $this->collRewritingsPartial = null;
+ }
+
+ /**
+ * reset is the collRewritings collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialRewritings($v = true)
+ {
+ $this->collRewritingsPartial = $v;
+ }
+
+ /**
+ * Initializes the collRewritings collection.
+ *
+ * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
+ * 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 initRewritings($overrideExisting = true)
+ {
+ if (null !== $this->collRewritings && !$overrideExisting) {
+ return;
+ }
+ $this->collRewritings = new PropelObjectCollection();
+ $this->collRewritings->setModel('Rewriting');
+ }
+
+ /**
+ * Gets an array of Rewriting 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|Rewriting[] List of Rewriting objects
* @throws PropelException
*/
- public function setRewriting(Rewriting $v = null)
+ public function getRewritings($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ // return empty collection
+ $this->initRewritings();
+ } else {
+ $collRewritings = RewritingQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collRewritingsPartial && count($collRewritings)) {
+ $this->initRewritings(false);
+
+ foreach($collRewritings as $obj) {
+ if (false == $this->collRewritings->contains($obj)) {
+ $this->collRewritings->append($obj);
+ }
+ }
+
+ $this->collRewritingsPartial = true;
+ }
+
+ return $collRewritings;
+ }
+
+ if($partial && $this->collRewritings) {
+ foreach($this->collRewritings as $obj) {
+ if($obj->isNew()) {
+ $collRewritings[] = $obj;
+ }
+ }
+ }
+
+ $this->collRewritings = $collRewritings;
+ $this->collRewritingsPartial = false;
+ }
+ }
+
+ return $this->collRewritings;
+ }
+
+ /**
+ * Sets a collection of Rewriting 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 $rewritings A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
+ {
+ $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
+
+ foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) {
+ $rewritingRemoved->setCategory(null);
+ }
+
+ $this->collRewritings = null;
+ foreach ($rewritings as $rewriting) {
+ $this->addRewriting($rewriting);
+ }
+
+ $this->collRewritings = $rewritings;
+ $this->collRewritingsPartial = false;
+ }
+
+ /**
+ * Returns the number of related Rewriting objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Rewriting objects.
+ * @throws PropelException
+ */
+ public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getRewritings());
+ }
+ $query = RewritingQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCategoryId());
+ return count($this->collRewritings);
}
+ }
- $this->aRewriting = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCategory($this);
+ /**
+ * Method called to associate a Rewriting object to this object
+ * through the Rewriting foreign key attribute.
+ *
+ * @param Rewriting $l Rewriting
+ * @return Category The current object (for fluent API support)
+ */
+ public function addRewriting(Rewriting $l)
+ {
+ if ($this->collRewritings === null) {
+ $this->initRewritings();
+ $this->collRewritingsPartial = true;
+ }
+ if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddRewriting($l);
}
-
return $this;
}
+ /**
+ * @param Rewriting $rewriting The rewriting object to add.
+ */
+ protected function doAddRewriting($rewriting)
+ {
+ $this->collRewritings[]= $rewriting;
+ $rewriting->setCategory($this);
+ }
/**
- * Get the associated Rewriting object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Rewriting The associated Rewriting object.
- * @throws PropelException
+ * @param Rewriting $rewriting The rewriting object to remove.
*/
- public function getRewriting(PropelPDO $con = null)
+ public function removeRewriting($rewriting)
{
- if ($this->aRewriting === null && ($this->id !== null)) {
- $this->aRewriting = RewritingQuery::create()
- ->filterByCategory($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aRewriting->setCategory($this);
+ if ($this->getRewritings()->contains($rewriting)) {
+ $this->collRewritings->remove($this->collRewritings->search($rewriting));
+ if (null === $this->rewritingsScheduledForDeletion) {
+ $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
+ $this->rewritingsScheduledForDeletion->clear();
+ }
+ $this->rewritingsScheduledForDeletion[]= $rewriting;
+ $rewriting->setCategory(null);
}
+ }
- return $this->aRewriting;
+
+ /**
+ * 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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getRewritings($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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Folder', $join_behavior);
+
+ return $this->getRewritings($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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Content', $join_behavior);
+
+ return $this->getRewritings($query, $con);
}
/**
@@ -1819,16 +3593,80 @@ 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) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatureCategorys) {
+ foreach ($this->collFeatureCategorys 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->collRewritings) {
+ foreach ($this->collRewritings as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aAttributeCategory = null;
- $this->aCategoryDesc = null;
- $this->aContentAssoc = null;
- $this->aDocument = null;
- $this->aFeatureCategory = null;
- $this->aImage = null;
- $this->aProductCategory = null;
- $this->aRewriting = null;
+ 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->collRewritings instanceof PropelCollection) {
+ $this->collRewritings->clearIterator();
+ }
+ $this->collRewritings = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCategoryDesc.php b/core/lib/Thelia/Model/om/BaseCategoryDesc.php
index 7d8789f44..4b24dc079 100644
--- a/core/lib/Thelia/Model/om/BaseCategoryDesc.php
+++ b/core/lib/Thelia/Model/om/BaseCategoryDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Category;
use Thelia\Model\CategoryDesc;
@@ -104,9 +102,9 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Category one-to-one related Category object
+ * @var Category
*/
- protected $singleCategory;
+ protected $aCategory;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -122,12 +120,6 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $categorysScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -310,6 +302,10 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = CategoryDescPeer::CATEGORY_ID;
}
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
return $this;
} // setCategoryId()
@@ -537,6 +533,9 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
} // ensureConsistency
/**
@@ -576,8 +575,7 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCategory = null;
-
+ $this->aCategory = null;
} // if (deep)
}
@@ -691,6 +689,18 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -702,21 +712,6 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->categorysScheduledForDeletion !== null) {
- if (!$this->categorysScheduledForDeletion->isEmpty()) {
- CategoryQuery::create()
- ->filterByPrimaryKeys($this->categorysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->categorysScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->isDeleted()) {
- $affectedRows += $this->singleCategory->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -902,17 +897,23 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+
if (($retval = CategoryDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCategory->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -1015,8 +1016,8 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
$keys[8] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCategory) {
- $result['Category'] = $this->singleCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1211,11 +1212,6 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCategory();
- if ($relObj) {
- $copyObj->setCategory($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1266,55 +1262,57 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Category object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Category object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Category
- * @throws PropelException
- */
- public function getCategory(PropelPDO $con = null)
- {
-
- if ($this->singleCategory === null && !$this->isNew()) {
- $this->singleCategory = CategoryQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCategory;
- }
-
- /**
- * Sets a single Category object as related to this object by a one-to-one relationship.
- *
- * @param Category $v Category
+ * @param Category $v
* @return CategoryDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setCategory(Category $v = null)
{
- $this->singleCategory = $v;
-
- // Make sure that that the passed-in Category isn't already associated with this object
- if ($v !== null && $v->getCategoryDesc() === null) {
- $v->setCategoryDesc($this);
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
}
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Category object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCategoryDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Category object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Category The associated Category object.
+ * @throws PropelException
+ */
+ public function getCategory(PropelPDO $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->category_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->aCategory->addCategoryDescs($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1349,15 +1347,9 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCategory) {
- $this->singleCategory->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCategory instanceof PropelCollection) {
- $this->singleCategory->clearIterator();
- }
- $this->singleCategory = null;
+ $this->aCategory = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCategoryDescPeer.php b/core/lib/Thelia/Model/om/BaseCategoryDescPeer.php
index 3a61cf3e2..eeb25a350 100644
--- a/core/lib/Thelia/Model/om/BaseCategoryDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCategoryDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseCategoryDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'category_desc';
@@ -403,9 +403,6 @@ abstract class BaseCategoryDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CategoryPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CategoryPeer::clearInstancePool();
}
/**
@@ -502,6 +499,244 @@ abstract class BaseCategoryDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CategoryDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CategoryDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CategoryDescPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of CategoryDesc objects pre-filled with their Category objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CategoryDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME);
+ }
+
+ CategoryDescPeer::addSelectColumns($criteria);
+ $startcol = CategoryDescPeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CategoryDescPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CategoryDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = CategoryDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CategoryDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (CategoryDesc) to $obj2 (Category)
+ $obj2->addCategoryDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CategoryDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CategoryDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CategoryDescPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of CategoryDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CategoryDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME);
+ }
+
+ CategoryDescPeer::addSelectColumns($criteria);
+ $startcol2 = CategoryDescPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CategoryDescPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CategoryDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = CategoryDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CategoryDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (CategoryDesc) to the collection in $obj2 (Category)
+ $obj2->addCategoryDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -635,7 +870,6 @@ abstract class BaseCategoryDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += CategoryDescPeer::doOnDeleteCascade(new Criteria(CategoryDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CategoryDescPeer::TABLE_NAME, $con, CategoryDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -669,14 +903,24 @@ abstract class BaseCategoryDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CategoryDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CategoryDesc) { // it's a model object
+ // invalidate the cache for this single object
+ CategoryDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CategoryDescPeer::DATABASE_NAME);
$criteria->add(CategoryDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CategoryDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -689,23 +933,6 @@ abstract class BaseCategoryDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += CategoryDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- CategoryDescPeer::clearInstancePool();
- } elseif ($values instanceof CategoryDesc) { // it's a model object
- CategoryDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- CategoryDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
CategoryDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -717,39 +944,6 @@ abstract class BaseCategoryDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = CategoryDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Category objects
- $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
-
- $criteria->add(CategoryPeer::ID, $obj->getCategoryId());
- $affectedRows += CategoryPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given CategoryDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php b/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php
index 0cc06dc7e..7472e3527 100644
--- a/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php
@@ -84,7 +84,7 @@ abstract class BaseCategoryDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\CategoryDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\CategoryDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -287,6 +287,8 @@ abstract class BaseCategoryDescQuery extends ModelCriteria
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
*
*
+ * @see filterByCategory()
+ *
* @param mixed $categoryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -552,7 +554,7 @@ abstract class BaseCategoryDescQuery extends ModelCriteria
/**
* Filter the query by a related Category object
*
- * @param Category|PropelObjectCollection $category the related object to use as filter
+ * @param Category|PropelObjectCollection $category The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CategoryDescQuery The current query, for fluid interface
@@ -564,10 +566,12 @@ abstract class BaseCategoryDescQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryDescPeer::CATEGORY_ID, $category->getId(), $comparison);
} elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCategoryQuery()
- ->filterByPrimaryKeys($category->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(CategoryDescPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseCategoryPeer.php b/core/lib/Thelia/Model/om/BaseCategoryPeer.php
index aee3a59e3..cda44319d 100644
--- a/core/lib/Thelia/Model/om/BaseCategoryPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCategoryPeer.php
@@ -32,7 +32,7 @@ abstract class BaseCategoryPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'category';
@@ -400,6 +400,30 @@ 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 RewritingPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ RewritingPeer::clearInstancePool();
}
/**
@@ -496,3501 +520,6 @@ abstract class BaseCategoryPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAttributeCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related CategoryDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinCategoryDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentAssoc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinContentAssoc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Document table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinDocument(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinFeatureCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Image table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinImage(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ProductCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinProductCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Rewriting table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinRewriting(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with their AttributeCategory objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAttributeCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol = CategoryPeer::NUM_HYDRATE_COLUMNS;
- AttributeCategoryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Category) to $obj2 (AttributeCategory)
- // one to one relationship
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with their CategoryDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinCategoryDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol = CategoryPeer::NUM_HYDRATE_COLUMNS;
- CategoryDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = CategoryDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- CategoryDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Category) to $obj2 (CategoryDesc)
- // one to one relationship
- $obj1->setCategoryDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with their ContentAssoc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinContentAssoc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol = CategoryPeer::NUM_HYDRATE_COLUMNS;
- ContentAssocPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Category) to $obj2 (ContentAssoc)
- // one to one relationship
- $obj1->setContentAssoc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with their Document objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol = CategoryPeer::NUM_HYDRATE_COLUMNS;
- DocumentPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = DocumentPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- DocumentPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Category) to $obj2 (Document)
- // one to one relationship
- $obj1->setDocument($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with their FeatureCategory objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinFeatureCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol = CategoryPeer::NUM_HYDRATE_COLUMNS;
- FeatureCategoryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = FeatureCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- FeatureCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Category) to $obj2 (FeatureCategory)
- // one to one relationship
- $obj1->setFeatureCategory($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with their Image objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol = CategoryPeer::NUM_HYDRATE_COLUMNS;
- ImagePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ImagePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ImagePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Category) to $obj2 (Image)
- // one to one relationship
- $obj1->setImage($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with their ProductCategory objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinProductCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol = CategoryPeer::NUM_HYDRATE_COLUMNS;
- ProductCategoryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ProductCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ProductCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Category) to $obj2 (ProductCategory)
- // one to one relationship
- $obj1->setProductCategory($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with their Rewriting objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinRewriting(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol = CategoryPeer::NUM_HYDRATE_COLUMNS;
- RewritingPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = RewritingPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- RewritingPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Category) to $obj2 (Rewriting)
- // one to one relationship
- $obj1->setRewriting($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- CategoryDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
- } // if joined row not null
-
- // Add objects for joined CategoryDesc rows
-
- $key3 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CategoryDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CategoryDescPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (CategoryDesc)
- $obj1->setCategoryDesc($obj3);
- } // if joined row not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
- } // if joined row not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if obj5 loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
- } // if joined row not null
-
- // Add objects for joined FeatureCategory rows
-
- $key6 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureCategoryPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureCategoryPeer::addInstanceToPool($obj6, $key6);
- } // if obj6 loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (FeatureCategory)
- $obj1->setFeatureCategory($obj6);
- } // if joined row not null
-
- // Add objects for joined Image rows
-
- $key7 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ImagePeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ImagePeer::addInstanceToPool($obj7, $key7);
- } // if obj7 loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (Image)
- $obj1->setImage($obj7);
- } // if joined row not null
-
- // Add objects for joined ProductCategory rows
-
- $key8 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductCategoryPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductCategoryPeer::addInstanceToPool($obj8, $key8);
- } // if obj8 loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (ProductCategory)
- $obj1->setProductCategory($obj8);
- } // if joined row not null
-
- // Add objects for joined Rewriting rows
-
- $key9 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = RewritingPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- RewritingPeer::addInstanceToPool($obj9, $key9);
- } // if obj9 loaded
-
- // Add the $obj1 (Category) to the collection in $obj9 (Rewriting)
- $obj1->setRewriting($obj9);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAttributeCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related CategoryDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptCategoryDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentAssoc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptContentAssoc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Document table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptDocument(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptFeatureCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Image table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptImage(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ProductCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptProductCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Rewriting table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptRewriting(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CategoryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects except AttributeCategory.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAttributeCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- CategoryDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined CategoryDesc rows
-
- $key2 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = CategoryDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- CategoryDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (CategoryDesc)
- $obj1->setCategoryDesc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key3 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentAssocPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentAssocPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (ContentAssoc)
- $obj1->setContentAssoc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key4 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = DocumentPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- DocumentPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (Document)
- $obj1->setDocument($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key5 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = FeatureCategoryPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- FeatureCategoryPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (FeatureCategory)
- $obj1->setFeatureCategory($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects except CategoryDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptCategoryDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key3 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentAssocPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentAssocPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (ContentAssoc)
- $obj1->setContentAssoc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key4 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = DocumentPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- DocumentPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (Document)
- $obj1->setDocument($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key5 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = FeatureCategoryPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- FeatureCategoryPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (FeatureCategory)
- $obj1->setFeatureCategory($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects except ContentAssoc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptContentAssoc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- CategoryDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined CategoryDesc rows
-
- $key3 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CategoryDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CategoryDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (CategoryDesc)
- $obj1->setCategoryDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key4 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = DocumentPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- DocumentPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (Document)
- $obj1->setDocument($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key5 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = FeatureCategoryPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- FeatureCategoryPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (FeatureCategory)
- $obj1->setFeatureCategory($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects except Document.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- CategoryDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined CategoryDesc rows
-
- $key3 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CategoryDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CategoryDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (CategoryDesc)
- $obj1->setCategoryDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key5 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = FeatureCategoryPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- FeatureCategoryPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (FeatureCategory)
- $obj1->setFeatureCategory($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects except FeatureCategory.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptFeatureCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- CategoryDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined CategoryDesc rows
-
- $key3 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CategoryDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CategoryDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (CategoryDesc)
- $obj1->setCategoryDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects except Image.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- CategoryDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined CategoryDesc rows
-
- $key3 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CategoryDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CategoryDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (CategoryDesc)
- $obj1->setCategoryDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key6 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureCategoryPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureCategoryPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (FeatureCategory)
- $obj1->setFeatureCategory($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects except ProductCategory.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptProductCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- CategoryDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, RewritingPeer::CATEGORY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined CategoryDesc rows
-
- $key3 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CategoryDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CategoryDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (CategoryDesc)
- $obj1->setCategoryDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key6 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureCategoryPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureCategoryPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (FeatureCategory)
- $obj1->setFeatureCategory($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key7 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ImagePeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ImagePeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (Image)
- $obj1->setImage($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Category objects pre-filled with all related objects except Rewriting.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Category objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptRewriting(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CategoryPeer::DATABASE_NAME);
- }
-
- CategoryPeer::addSelectColumns($criteria);
- $startcol2 = CategoryPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- CategoryDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, CategoryDescPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ContentAssocPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, DocumentPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, FeatureCategoryPeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ImagePeer::CATEGORY_ID, $join_behavior);
-
- $criteria->addJoin(CategoryPeer::ID, ProductCategoryPeer::CATEGORY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CategoryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CategoryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CategoryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCategory rows
-
- $key2 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj2 (AttributeCategory)
- $obj1->setAttributeCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined CategoryDesc rows
-
- $key3 = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CategoryDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CategoryDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CategoryDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj3 (CategoryDesc)
- $obj1->setCategoryDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key6 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureCategoryPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureCategoryPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj6 (FeatureCategory)
- $obj1->setFeatureCategory($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key7 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ImagePeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ImagePeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj7 (Image)
- $obj1->setImage($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key8 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductCategoryPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductCategoryPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Category) to the collection in $obj8 (ProductCategory)
- $obj1->setProductCategory($obj8);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseCategoryQuery.php b/core/lib/Thelia/Model/om/BaseCategoryQuery.php
index aa55b8c55..fdd8e09ee 100644
--- a/core/lib/Thelia/Model/om/BaseCategoryQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCategoryQuery.php
@@ -111,7 +111,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Category', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Category', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -287,22 +287,6 @@ abstract class BaseCategoryQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAttributeCategory()
- *
- * @see filterByCategoryDesc()
- *
- * @see filterByContentAssoc()
- *
- * @see filterByDocument()
- *
- * @see filterByFeatureCategory()
- *
- * @see filterByImage()
- *
- * @see filterByProductCategory()
- *
- * @see filterByRewriting()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -561,7 +545,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
/**
* Filter the query by a related AttributeCategory object
*
- * @param AttributeCategory|PropelObjectCollection $attributeCategory The related object(s) 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 CategoryQuery The current query, for fluid interface
@@ -573,12 +557,10 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryPeer::ID, $attributeCategory->getCategoryId(), $comparison);
} elseif ($attributeCategory instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CategoryPeer::ID, $attributeCategory->toKeyValue('PrimaryKey', 'CategoryId'), $comparison);
+ ->useAttributeCategoryQuery()
+ ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection');
}
@@ -637,7 +619,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
/**
* Filter the query by a related CategoryDesc object
*
- * @param CategoryDesc|PropelObjectCollection $categoryDesc The related object(s) to use as filter
+ * @param CategoryDesc|PropelObjectCollection $categoryDesc 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
@@ -649,12 +631,10 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryPeer::ID, $categoryDesc->getCategoryId(), $comparison);
} elseif ($categoryDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CategoryPeer::ID, $categoryDesc->toKeyValue('PrimaryKey', 'CategoryId'), $comparison);
+ ->useCategoryDescQuery()
+ ->filterByPrimaryKeys($categoryDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByCategoryDesc() only accepts arguments of type CategoryDesc or PropelCollection');
}
@@ -713,7 +693,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
/**
* Filter the query by a related ContentAssoc object
*
- * @param ContentAssoc|PropelObjectCollection $contentAssoc The related object(s) 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 CategoryQuery The current query, for fluid interface
@@ -725,12 +705,10 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryPeer::ID, $contentAssoc->getCategoryId(), $comparison);
} elseif ($contentAssoc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CategoryPeer::ID, $contentAssoc->toKeyValue('PrimaryKey', 'CategoryId'), $comparison);
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection');
}
@@ -744,7 +722,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*
* @return CategoryQuery The current query, for fluid interface
*/
- public function joinContentAssoc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('ContentAssoc');
@@ -779,7 +757,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*
* @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
*/
- public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinContentAssoc($relationAlias, $joinType)
@@ -789,7 +767,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
/**
* Filter the query by a related Document object
*
- * @param Document|PropelObjectCollection $document The related object(s) 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
@@ -801,12 +779,10 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryPeer::ID, $document->getCategoryId(), $comparison);
} elseif ($document instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CategoryPeer::ID, $document->toKeyValue('PrimaryKey', 'CategoryId'), $comparison);
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
}
@@ -820,7 +796,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*
* @return CategoryQuery The current query, for fluid interface
*/
- public function joinDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Document');
@@ -855,7 +831,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*
* @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
*/
- public function useDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinDocument($relationAlias, $joinType)
@@ -865,7 +841,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
/**
* Filter the query by a related FeatureCategory object
*
- * @param FeatureCategory|PropelObjectCollection $featureCategory The related object(s) to use as filter
+ * @param FeatureCategory|PropelObjectCollection $featureCategory the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CategoryQuery The current query, for fluid interface
@@ -877,12 +853,10 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryPeer::ID, $featureCategory->getCategoryId(), $comparison);
} elseif ($featureCategory instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CategoryPeer::ID, $featureCategory->toKeyValue('PrimaryKey', 'CategoryId'), $comparison);
+ ->useFeatureCategoryQuery()
+ ->filterByPrimaryKeys($featureCategory->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection');
}
@@ -941,7 +915,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
/**
* Filter the query by a related Image object
*
- * @param Image|PropelObjectCollection $image The related object(s) to use as filter
+ * @param Image|PropelObjectCollection $image the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CategoryQuery The current query, for fluid interface
@@ -953,12 +927,10 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryPeer::ID, $image->getCategoryId(), $comparison);
} elseif ($image instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CategoryPeer::ID, $image->toKeyValue('PrimaryKey', 'CategoryId'), $comparison);
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
}
@@ -972,7 +944,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*
* @return CategoryQuery The current query, for fluid interface
*/
- public function joinImage($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Image');
@@ -1007,7 +979,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*
* @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
*/
- public function useImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinImage($relationAlias, $joinType)
@@ -1017,7 +989,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
/**
* Filter the query by a related ProductCategory object
*
- * @param ProductCategory|PropelObjectCollection $productCategory The related object(s) 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
@@ -1029,12 +1001,10 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryPeer::ID, $productCategory->getCategoryId(), $comparison);
} elseif ($productCategory instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CategoryPeer::ID, $productCategory->toKeyValue('CategoryId', 'CategoryId'), $comparison);
+ ->useProductCategoryQuery()
+ ->filterByPrimaryKeys($productCategory->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection');
}
@@ -1093,7 +1063,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
/**
* Filter the query by a related Rewriting object
*
- * @param Rewriting|PropelObjectCollection $rewriting The related object(s) to use as filter
+ * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CategoryQuery The current query, for fluid interface
@@ -1105,12 +1075,10 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(CategoryPeer::ID, $rewriting->getCategoryId(), $comparison);
} elseif ($rewriting instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CategoryPeer::ID, $rewriting->toKeyValue('PrimaryKey', 'CategoryId'), $comparison);
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection');
}
@@ -1124,7 +1092,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*
* @return CategoryQuery The current query, for fluid interface
*/
- public function joinRewriting($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Rewriting');
@@ -1159,7 +1127,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*
* @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query
*/
- public function useRewritingQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinRewriting($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseCombination.php b/core/lib/Thelia/Model/om/BaseCombination.php
index 5114c8553..c692e5cdc 100644
--- a/core/lib/Thelia/Model/om/BaseCombination.php
+++ b/core/lib/Thelia/Model/om/BaseCombination.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\AttributeCombination;
use Thelia\Model\AttributeCombinationQuery;
@@ -74,14 +76,16 @@ abstract class BaseCombination extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var AttributeCombination
+ * @var PropelObjectCollection|AttributeCombination[] Collection to store aggregation of AttributeCombination objects.
*/
- protected $aAttributeCombination;
+ protected $collAttributeCombinations;
+ protected $collAttributeCombinationsPartial;
/**
- * @var Stock
+ * @var PropelObjectCollection|Stock[] Collection to store aggregation of Stock objects.
*/
- protected $aStock;
+ protected $collStocks;
+ protected $collStocksPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -97,6 +101,18 @@ abstract class BaseCombination extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $attributeCombinationsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $stocksScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -208,14 +224,6 @@ abstract class BaseCombination extends BaseObject implements Persistent
$this->modifiedColumns[] = CombinationPeer::ID;
}
- if ($this->aAttributeCombination !== null && $this->aAttributeCombination->getCombinationId() !== $v) {
- $this->aAttributeCombination = null;
- }
-
- if ($this->aStock !== null && $this->aStock->getCombinationId() !== $v) {
- $this->aStock = null;
- }
-
return $this;
} // setId()
@@ -354,12 +362,6 @@ abstract class BaseCombination extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAttributeCombination !== null && $this->id !== $this->aAttributeCombination->getCombinationId()) {
- $this->aAttributeCombination = null;
- }
- if ($this->aStock !== null && $this->id !== $this->aStock->getCombinationId()) {
- $this->aStock = null;
- }
} // ensureConsistency
/**
@@ -399,8 +401,10 @@ abstract class BaseCombination extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAttributeCombination = null;
- $this->aStock = null;
+ $this->collAttributeCombinations = null;
+
+ $this->collStocks = null;
+
} // if (deep)
}
@@ -514,25 +518,6 @@ abstract class BaseCombination extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAttributeCombination !== null) {
- if ($this->aAttributeCombination->isModified() || $this->aAttributeCombination->isNew()) {
- $affectedRows += $this->aAttributeCombination->save($con);
- }
- $this->setAttributeCombination($this->aAttributeCombination);
- }
-
- if ($this->aStock !== null) {
- if ($this->aStock->isModified() || $this->aStock->isNew()) {
- $affectedRows += $this->aStock->save($con);
- }
- $this->setStock($this->aStock);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -544,6 +529,41 @@ abstract class BaseCombination extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->attributeCombinationsScheduledForDeletion !== null) {
+ if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) {
+ AttributeCombinationQuery::create()
+ ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeCombinationsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->stocksScheduledForDeletion !== null) {
+ if (!$this->stocksScheduledForDeletion->isEmpty()) {
+ foreach ($this->stocksScheduledForDeletion as $stock) {
+ // need to save related object because we set the relation to null
+ $stock->save($con);
+ }
+ $this->stocksScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collStocks !== null) {
+ foreach ($this->collStocks as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -699,29 +719,27 @@ abstract class BaseCombination extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAttributeCombination !== null) {
- if (!$this->aAttributeCombination->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAttributeCombination->getValidationFailures());
- }
- }
-
- if ($this->aStock !== null) {
- if (!$this->aStock->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aStock->getValidationFailures());
- }
- }
-
-
if (($retval = CombinationPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations 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());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -804,11 +822,11 @@ abstract class BaseCombination extends BaseObject implements Persistent
$keys[3] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAttributeCombination) {
- $result['AttributeCombination'] = $this->aAttributeCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aStock) {
- $result['Stock'] = $this->aStock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collStocks) {
+ $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -973,14 +991,16 @@ abstract class BaseCombination extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAttributeCombination();
- if ($relObj) {
- $copyObj->setAttributeCombination($relObj->copy($deepCopy));
+ foreach ($this->getAttributeCombinations() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCombination($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getStock();
- if ($relObj) {
- $copyObj->setStock($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
@@ -1033,98 +1053,512 @@ abstract class BaseCombination extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a AttributeCombination object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param AttributeCombination $v
- * @return Combination The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AttributeCombination' == $relationName) {
+ $this->initAttributeCombinations();
+ }
+ if ('Stock' == $relationName) {
+ $this->initStocks();
+ }
+ }
+
+ /**
+ * Clears out the collAttributeCombinations 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 addAttributeCombinations()
+ */
+ public function clearAttributeCombinations()
+ {
+ $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized
+ $this->collAttributeCombinationsPartial = null;
+ }
+
+ /**
+ * reset is the collAttributeCombinations collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAttributeCombinations($v = true)
+ {
+ $this->collAttributeCombinationsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCombinations collection.
+ *
+ * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations());
+ * 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 initAttributeCombinations($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCombinations && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCombinations = new PropelObjectCollection();
+ $this->collAttributeCombinations->setModel('AttributeCombination');
+ }
+
+ /**
+ * Gets an array of AttributeCombination 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 Combination 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|AttributeCombination[] List of AttributeCombination objects
* @throws PropelException
*/
- public function setAttributeCombination(AttributeCombination $v = null)
+ public function getAttributeCombinations($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ // return empty collection
+ $this->initAttributeCombinations();
+ } else {
+ $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria)
+ ->filterByCombination($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) {
+ $this->initAttributeCombinations(false);
+
+ foreach($collAttributeCombinations as $obj) {
+ if (false == $this->collAttributeCombinations->contains($obj)) {
+ $this->collAttributeCombinations->append($obj);
+ }
+ }
+
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ return $collAttributeCombinations;
+ }
+
+ if($partial && $this->collAttributeCombinations) {
+ foreach($this->collAttributeCombinations as $obj) {
+ if($obj->isNew()) {
+ $collAttributeCombinations[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCombinations = $collAttributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+ }
+
+ return $this->collAttributeCombinations;
+ }
+
+ /**
+ * Sets a collection of AttributeCombination 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 $attributeCombinations A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null)
+ {
+ $this->attributeCombinationsScheduledForDeletion = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations);
+
+ foreach ($this->attributeCombinationsScheduledForDeletion as $attributeCombinationRemoved) {
+ $attributeCombinationRemoved->setCombination(null);
+ }
+
+ $this->collAttributeCombinations = null;
+ foreach ($attributeCombinations as $attributeCombination) {
+ $this->addAttributeCombination($attributeCombination);
+ }
+
+ $this->collAttributeCombinations = $attributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+
+ /**
+ * Returns the number of related AttributeCombination objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AttributeCombination objects.
+ * @throws PropelException
+ */
+ public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAttributeCombinations());
+ }
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCombination($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCombinationId());
+ return count($this->collAttributeCombinations);
}
+ }
- $this->aAttributeCombination = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCombination($this);
+ /**
+ * Method called to associate a AttributeCombination object to this object
+ * through the AttributeCombination foreign key attribute.
+ *
+ * @param AttributeCombination $l AttributeCombination
+ * @return Combination The current object (for fluent API support)
+ */
+ public function addAttributeCombination(AttributeCombination $l)
+ {
+ if ($this->collAttributeCombinations === null) {
+ $this->initAttributeCombinations();
+ $this->collAttributeCombinationsPartial = true;
+ }
+ if (!$this->collAttributeCombinations->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCombination($l);
}
-
return $this;
}
-
/**
- * Get the associated AttributeCombination object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AttributeCombination The associated AttributeCombination object.
- * @throws PropelException
+ * @param AttributeCombination $attributeCombination The attributeCombination object to add.
*/
- public function getAttributeCombination(PropelPDO $con = null)
+ protected function doAddAttributeCombination($attributeCombination)
{
- if ($this->aAttributeCombination === null && ($this->id !== null)) {
- $this->aAttributeCombination = AttributeCombinationQuery::create()
- ->filterByCombination($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAttributeCombination->setCombination($this);
- }
-
- return $this->aAttributeCombination;
+ $this->collAttributeCombinations[]= $attributeCombination;
+ $attributeCombination->setCombination($this);
}
/**
- * Declares an association between this object and a Stock object.
+ * @param AttributeCombination $attributeCombination The attributeCombination object to remove.
+ */
+ public function removeAttributeCombination($attributeCombination)
+ {
+ if ($this->getAttributeCombinations()->contains($attributeCombination)) {
+ $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination));
+ if (null === $this->attributeCombinationsScheduledForDeletion) {
+ $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations;
+ $this->attributeCombinationsScheduledForDeletion->clear();
+ }
+ $this->attributeCombinationsScheduledForDeletion[]= $attributeCombination;
+ $attributeCombination->setCombination(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Combination is new, it will return
+ * an empty collection; or if this Combination has previously
+ * been saved, it will retrieve related AttributeCombinations from storage.
*
- * @param Stock $v
- * @return Combination The current object (for fluent API support)
+ * 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 Combination.
+ *
+ * @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|AttributeCombination[] List of AttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('Attribute', $join_behavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Combination is new, it will return
+ * an empty collection; or if this Combination has previously
+ * been saved, it will retrieve related AttributeCombinations 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 Combination.
+ *
+ * @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|AttributeCombination[] List of AttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('AttributeAv', $join_behavior);
+
+ return $this->getAttributeCombinations($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 Combination 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 setStock(Stock $v = null)
+ public function getStocks($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByCombination($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->setCombination(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
+ ->filterByCombination($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCombinationId());
+ return count($this->collStocks);
}
+ }
- $this->aStock = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCombination($this);
+ /**
+ * Method called to associate a Stock object to this object
+ * through the Stock foreign key attribute.
+ *
+ * @param Stock $l Stock
+ * @return Combination 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->setCombination($this);
+ }
/**
- * Get the associated Stock object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Stock The associated Stock object.
- * @throws PropelException
+ * @param Stock $stock The stock object to remove.
*/
- public function getStock(PropelPDO $con = null)
+ public function removeStock($stock)
{
- if ($this->aStock === null && ($this->id !== null)) {
- $this->aStock = StockQuery::create()
- ->filterByCombination($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aStock->setCombination($this);
+ 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->setCombination(null);
}
+ }
- return $this->aStock;
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Combination is new, it will return
+ * an empty collection; or if this Combination 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 Combination.
+ *
+ * @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 getStocksJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = StockQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getStocks($query, $con);
}
/**
@@ -1156,10 +1590,26 @@ abstract class BaseCombination extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collStocks) {
+ foreach ($this->collStocks as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aAttributeCombination = null;
- $this->aStock = null;
+ if ($this->collAttributeCombinations instanceof PropelCollection) {
+ $this->collAttributeCombinations->clearIterator();
+ }
+ $this->collAttributeCombinations = null;
+ if ($this->collStocks instanceof PropelCollection) {
+ $this->collStocks->clearIterator();
+ }
+ $this->collStocks = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCombinationPeer.php b/core/lib/Thelia/Model/om/BaseCombinationPeer.php
index 434157230..19c0b38ba 100644
--- a/core/lib/Thelia/Model/om/BaseCombinationPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCombinationPeer.php
@@ -26,7 +26,7 @@ abstract class BaseCombinationPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'combination';
@@ -379,6 +379,12 @@ abstract class BaseCombinationPeer
*/
public static function clearRelatedInstancePool()
{
+ // 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 StockPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ StockPeer::clearInstancePool();
}
/**
@@ -475,639 +481,6 @@ abstract class BaseCombinationPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCombination table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAttributeCombination(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CombinationPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CombinationPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CombinationPeer::ID, AttributeCombinationPeer::COMBINATION_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Stock table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinStock(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CombinationPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CombinationPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CombinationPeer::ID, StockPeer::COMBINATION_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Combination objects pre-filled with their AttributeCombination objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Combination objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAttributeCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
- }
-
- CombinationPeer::addSelectColumns($criteria);
- $startcol = CombinationPeer::NUM_HYDRATE_COLUMNS;
- AttributeCombinationPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CombinationPeer::ID, AttributeCombinationPeer::COMBINATION_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CombinationPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CombinationPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CombinationPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CombinationPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AttributeCombinationPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AttributeCombinationPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Combination) to $obj2 (AttributeCombination)
- // one to one relationship
- $obj1->setAttributeCombination($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Combination objects pre-filled with their Stock objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Combination objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinStock(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
- }
-
- CombinationPeer::addSelectColumns($criteria);
- $startcol = CombinationPeer::NUM_HYDRATE_COLUMNS;
- StockPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CombinationPeer::ID, StockPeer::COMBINATION_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CombinationPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CombinationPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CombinationPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CombinationPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = StockPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = StockPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- StockPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Combination) to $obj2 (Stock)
- // one to one relationship
- $obj1->setStock($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CombinationPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CombinationPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CombinationPeer::ID, AttributeCombinationPeer::COMBINATION_ID, $join_behavior);
-
- $criteria->addJoin(CombinationPeer::ID, StockPeer::COMBINATION_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Combination objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Combination objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
- }
-
- CombinationPeer::addSelectColumns($criteria);
- $startcol2 = CombinationPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCombinationPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CombinationPeer::ID, AttributeCombinationPeer::COMBINATION_ID, $join_behavior);
-
- $criteria->addJoin(CombinationPeer::ID, StockPeer::COMBINATION_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CombinationPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CombinationPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CombinationPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CombinationPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCombination rows
-
- $key2 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCombinationPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCombinationPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Combination) to the collection in $obj2 (AttributeCombination)
- $obj1->setAttributeCombination($obj2);
- } // if joined row not null
-
- // Add objects for joined Stock rows
-
- $key3 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = StockPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = StockPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- StockPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Combination) to the collection in $obj3 (Stock)
- $obj1->setStock($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AttributeCombination table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAttributeCombination(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CombinationPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CombinationPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CombinationPeer::ID, StockPeer::COMBINATION_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Stock table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptStock(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CombinationPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CombinationPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CombinationPeer::ID, AttributeCombinationPeer::COMBINATION_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Combination objects pre-filled with all related objects except AttributeCombination.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Combination objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAttributeCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
- }
-
- CombinationPeer::addSelectColumns($criteria);
- $startcol2 = CombinationPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CombinationPeer::ID, StockPeer::COMBINATION_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CombinationPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CombinationPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CombinationPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CombinationPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Stock rows
-
- $key2 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = StockPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = StockPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- StockPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Combination) to the collection in $obj2 (Stock)
- $obj1->setStock($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Combination objects pre-filled with all related objects except Stock.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Combination objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptStock(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CombinationPeer::DATABASE_NAME);
- }
-
- CombinationPeer::addSelectColumns($criteria);
- $startcol2 = CombinationPeer::NUM_HYDRATE_COLUMNS;
-
- AttributeCombinationPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CombinationPeer::ID, AttributeCombinationPeer::COMBINATION_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CombinationPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CombinationPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CombinationPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CombinationPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AttributeCombination rows
-
- $key2 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AttributeCombinationPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AttributeCombinationPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AttributeCombinationPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Combination) to the collection in $obj2 (AttributeCombination)
- $obj1->setAttributeCombination($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseCombinationQuery.php b/core/lib/Thelia/Model/om/BaseCombinationQuery.php
index 7287e91bc..a1e4e3d5f 100644
--- a/core/lib/Thelia/Model/om/BaseCombinationQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCombinationQuery.php
@@ -69,7 +69,7 @@ abstract class BaseCombinationQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Combination', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Combination', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -245,10 +245,6 @@ abstract class BaseCombinationQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAttributeCombination()
- *
- * @see filterByStock()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -384,7 +380,7 @@ abstract class BaseCombinationQuery extends ModelCriteria
/**
* Filter the query by a related AttributeCombination object
*
- * @param AttributeCombination|PropelObjectCollection $attributeCombination The related object(s) to use as filter
+ * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CombinationQuery The current query, for fluid interface
@@ -396,12 +392,10 @@ abstract class BaseCombinationQuery extends ModelCriteria
return $this
->addUsingAlias(CombinationPeer::ID, $attributeCombination->getCombinationId(), $comparison);
} elseif ($attributeCombination instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CombinationPeer::ID, $attributeCombination->toKeyValue('CombinationId', 'CombinationId'), $comparison);
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection');
}
@@ -460,7 +454,7 @@ abstract class BaseCombinationQuery extends ModelCriteria
/**
* Filter the query by a related Stock object
*
- * @param Stock|PropelObjectCollection $stock The related object(s) to use as filter
+ * @param Stock|PropelObjectCollection $stock the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CombinationQuery The current query, for fluid interface
@@ -472,12 +466,10 @@ abstract class BaseCombinationQuery extends ModelCriteria
return $this
->addUsingAlias(CombinationPeer::ID, $stock->getCombinationId(), $comparison);
} elseif ($stock instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CombinationPeer::ID, $stock->toKeyValue('PrimaryKey', 'CombinationId'), $comparison);
+ ->useStockQuery()
+ ->filterByPrimaryKeys($stock->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection');
}
@@ -491,7 +483,7 @@ abstract class BaseCombinationQuery extends ModelCriteria
*
* @return CombinationQuery The current query, for fluid interface
*/
- public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinStock($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Stock');
@@ -526,7 +518,7 @@ abstract class BaseCombinationQuery extends ModelCriteria
*
* @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query
*/
- public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useStockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinStock($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseConfig.php b/core/lib/Thelia/Model/om/BaseConfig.php
index a823484b2..5bb82ad08 100644
--- a/core/lib/Thelia/Model/om/BaseConfig.php
+++ b/core/lib/Thelia/Model/om/BaseConfig.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Config;
use Thelia\Model\ConfigDesc;
@@ -92,9 +94,10 @@ abstract class BaseConfig extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var ConfigDesc
+ * @var PropelObjectCollection|ConfigDesc[] Collection to store aggregation of ConfigDesc objects.
*/
- protected $aConfigDesc;
+ protected $collConfigDescs;
+ protected $collConfigDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -110,6 +113,12 @@ abstract class BaseConfig extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $configDescsScheduledForDeletion = null;
+
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
@@ -273,10 +282,6 @@ abstract class BaseConfig extends BaseObject implements Persistent
$this->modifiedColumns[] = ConfigPeer::ID;
}
- if ($this->aConfigDesc !== null && $this->aConfigDesc->getConfigId() !== $v) {
- $this->aConfigDesc = null;
- }
-
return $this;
} // setId()
@@ -489,9 +494,6 @@ abstract class BaseConfig extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aConfigDesc !== null && $this->id !== $this->aConfigDesc->getConfigId()) {
- $this->aConfigDesc = null;
- }
} // ensureConsistency
/**
@@ -531,7 +533,8 @@ abstract class BaseConfig extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aConfigDesc = null;
+ $this->collConfigDescs = null;
+
} // if (deep)
}
@@ -645,18 +648,6 @@ abstract class BaseConfig extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aConfigDesc !== null) {
- if ($this->aConfigDesc->isModified() || $this->aConfigDesc->isNew()) {
- $affectedRows += $this->aConfigDesc->save($con);
- }
- $this->setConfigDesc($this->aConfigDesc);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -668,6 +659,23 @@ abstract class BaseConfig extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->configDescsScheduledForDeletion !== null) {
+ if (!$this->configDescsScheduledForDeletion->isEmpty()) {
+ ConfigDescQuery::create()
+ ->filterByPrimaryKeys($this->configDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->configDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collConfigDescs !== null) {
+ foreach ($this->collConfigDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -841,23 +849,19 @@ abstract class BaseConfig extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aConfigDesc !== null) {
- if (!$this->aConfigDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aConfigDesc->getValidationFailures());
- }
- }
-
-
if (($retval = ConfigPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collConfigDescs !== null) {
+ foreach ($this->collConfigDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -952,8 +956,8 @@ abstract class BaseConfig extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aConfigDesc) {
- $result['ConfigDesc'] = $this->aConfigDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collConfigDescs) {
+ $result['ConfigDescs'] = $this->collConfigDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1136,9 +1140,10 @@ abstract class BaseConfig extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getConfigDesc();
- if ($relObj) {
- $copyObj->setConfigDesc($relObj->copy($deepCopy));
+ foreach ($this->getConfigDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addConfigDesc($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1191,51 +1196,227 @@ abstract class BaseConfig extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a ConfigDesc object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param ConfigDesc $v
- * @return Config The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('ConfigDesc' == $relationName) {
+ $this->initConfigDescs();
+ }
+ }
+
+ /**
+ * Clears out the collConfigDescs 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 addConfigDescs()
+ */
+ public function clearConfigDescs()
+ {
+ $this->collConfigDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collConfigDescsPartial = null;
+ }
+
+ /**
+ * reset is the collConfigDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialConfigDescs($v = true)
+ {
+ $this->collConfigDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collConfigDescs collection.
+ *
+ * By default this just sets the collConfigDescs collection to an empty array (like clearcollConfigDescs());
+ * 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 initConfigDescs($overrideExisting = true)
+ {
+ if (null !== $this->collConfigDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collConfigDescs = new PropelObjectCollection();
+ $this->collConfigDescs->setModel('ConfigDesc');
+ }
+
+ /**
+ * Gets an array of ConfigDesc 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 Config 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|ConfigDesc[] List of ConfigDesc objects
* @throws PropelException
*/
- public function setConfigDesc(ConfigDesc $v = null)
+ public function getConfigDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collConfigDescsPartial && !$this->isNew();
+ if (null === $this->collConfigDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collConfigDescs) {
+ // return empty collection
+ $this->initConfigDescs();
+ } else {
+ $collConfigDescs = ConfigDescQuery::create(null, $criteria)
+ ->filterByConfig($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collConfigDescsPartial && count($collConfigDescs)) {
+ $this->initConfigDescs(false);
+
+ foreach($collConfigDescs as $obj) {
+ if (false == $this->collConfigDescs->contains($obj)) {
+ $this->collConfigDescs->append($obj);
+ }
+ }
+
+ $this->collConfigDescsPartial = true;
+ }
+
+ return $collConfigDescs;
+ }
+
+ if($partial && $this->collConfigDescs) {
+ foreach($this->collConfigDescs as $obj) {
+ if($obj->isNew()) {
+ $collConfigDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collConfigDescs = $collConfigDescs;
+ $this->collConfigDescsPartial = false;
+ }
+ }
+
+ return $this->collConfigDescs;
+ }
+
+ /**
+ * Sets a collection of ConfigDesc 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 $configDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setConfigDescs(PropelCollection $configDescs, PropelPDO $con = null)
+ {
+ $this->configDescsScheduledForDeletion = $this->getConfigDescs(new Criteria(), $con)->diff($configDescs);
+
+ foreach ($this->configDescsScheduledForDeletion as $configDescRemoved) {
+ $configDescRemoved->setConfig(null);
+ }
+
+ $this->collConfigDescs = null;
+ foreach ($configDescs as $configDesc) {
+ $this->addConfigDesc($configDesc);
+ }
+
+ $this->collConfigDescs = $configDescs;
+ $this->collConfigDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related ConfigDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ConfigDesc objects.
+ * @throws PropelException
+ */
+ public function countConfigDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collConfigDescsPartial && !$this->isNew();
+ if (null === $this->collConfigDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collConfigDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getConfigDescs());
+ }
+ $query = ConfigDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByConfig($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getConfigId());
+ return count($this->collConfigDescs);
}
+ }
- $this->aConfigDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setConfig($this);
+ /**
+ * Method called to associate a ConfigDesc object to this object
+ * through the ConfigDesc foreign key attribute.
+ *
+ * @param ConfigDesc $l ConfigDesc
+ * @return Config The current object (for fluent API support)
+ */
+ public function addConfigDesc(ConfigDesc $l)
+ {
+ if ($this->collConfigDescs === null) {
+ $this->initConfigDescs();
+ $this->collConfigDescsPartial = true;
+ }
+ if (!$this->collConfigDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddConfigDesc($l);
}
-
return $this;
}
+ /**
+ * @param ConfigDesc $configDesc The configDesc object to add.
+ */
+ protected function doAddConfigDesc($configDesc)
+ {
+ $this->collConfigDescs[]= $configDesc;
+ $configDesc->setConfig($this);
+ }
/**
- * Get the associated ConfigDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ConfigDesc The associated ConfigDesc object.
- * @throws PropelException
+ * @param ConfigDesc $configDesc The configDesc object to remove.
*/
- public function getConfigDesc(PropelPDO $con = null)
+ public function removeConfigDesc($configDesc)
{
- if ($this->aConfigDesc === null && ($this->id !== null)) {
- $this->aConfigDesc = ConfigDescQuery::create()
- ->filterByConfig($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aConfigDesc->setConfig($this);
+ if ($this->getConfigDescs()->contains($configDesc)) {
+ $this->collConfigDescs->remove($this->collConfigDescs->search($configDesc));
+ if (null === $this->configDescsScheduledForDeletion) {
+ $this->configDescsScheduledForDeletion = clone $this->collConfigDescs;
+ $this->configDescsScheduledForDeletion->clear();
+ }
+ $this->configDescsScheduledForDeletion[]= $configDesc;
+ $configDesc->setConfig(null);
}
-
- return $this->aConfigDesc;
}
/**
@@ -1271,9 +1452,17 @@ abstract class BaseConfig extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collConfigDescs) {
+ foreach ($this->collConfigDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aConfigDesc = null;
+ if ($this->collConfigDescs instanceof PropelCollection) {
+ $this->collConfigDescs->clearIterator();
+ }
+ $this->collConfigDescs = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseConfigDesc.php b/core/lib/Thelia/Model/om/BaseConfigDesc.php
index 967730b97..10b5dcb67 100644
--- a/core/lib/Thelia/Model/om/BaseConfigDesc.php
+++ b/core/lib/Thelia/Model/om/BaseConfigDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Config;
use Thelia\Model\ConfigDesc;
@@ -98,9 +96,9 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Config one-to-one related Config object
+ * @var Config
*/
- protected $singleConfig;
+ protected $aConfig;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $configsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -294,6 +286,10 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = ConfigDescPeer::CONFIG_ID;
}
+ if ($this->aConfig !== null && $this->aConfig->getId() !== $v) {
+ $this->aConfig = null;
+ }
+
return $this;
} // setConfigId()
@@ -499,6 +495,9 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aConfig !== null && $this->config_id !== $this->aConfig->getId()) {
+ $this->aConfig = null;
+ }
} // ensureConsistency
/**
@@ -538,8 +537,7 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleConfig = null;
-
+ $this->aConfig = null;
} // if (deep)
}
@@ -653,6 +651,18 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aConfig !== null) {
+ if ($this->aConfig->isModified() || $this->aConfig->isNew()) {
+ $affectedRows += $this->aConfig->save($con);
+ }
+ $this->setConfig($this->aConfig);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -664,21 +674,6 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->configsScheduledForDeletion !== null) {
- if (!$this->configsScheduledForDeletion->isEmpty()) {
- ConfigQuery::create()
- ->filterByPrimaryKeys($this->configsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->configsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleConfig !== null) {
- if (!$this->singleConfig->isDeleted()) {
- $affectedRows += $this->singleConfig->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -858,17 +853,23 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aConfig !== null) {
+ if (!$this->aConfig->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aConfig->getValidationFailures());
+ }
+ }
+
+
if (($retval = ConfigDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleConfig !== null) {
- if (!$this->singleConfig->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleConfig->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -967,8 +968,8 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleConfig) {
- $result['Config'] = $this->singleConfig->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aConfig) {
+ $result['Config'] = $this->aConfig->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1157,11 +1158,6 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getConfig();
- if ($relObj) {
- $copyObj->setConfig($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1212,55 +1208,57 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Config object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Config object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Config
- * @throws PropelException
- */
- public function getConfig(PropelPDO $con = null)
- {
-
- if ($this->singleConfig === null && !$this->isNew()) {
- $this->singleConfig = ConfigQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleConfig;
- }
-
- /**
- * Sets a single Config object as related to this object by a one-to-one relationship.
- *
- * @param Config $v Config
+ * @param Config $v
* @return ConfigDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setConfig(Config $v = null)
{
- $this->singleConfig = $v;
-
- // Make sure that that the passed-in Config isn't already associated with this object
- if ($v !== null && $v->getConfigDesc() === null) {
- $v->setConfigDesc($this);
+ if ($v === null) {
+ $this->setConfigId(NULL);
+ } else {
+ $this->setConfigId($v->getId());
}
+ $this->aConfig = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Config object, it will not be re-added.
+ if ($v !== null) {
+ $v->addConfigDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Config object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Config The associated Config object.
+ * @throws PropelException
+ */
+ public function getConfig(PropelPDO $con = null)
+ {
+ if ($this->aConfig === null && ($this->config_id !== null)) {
+ $this->aConfig = ConfigQuery::create()->findPk($this->config_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->aConfig->addConfigDescs($this);
+ */
+ }
+
+ return $this->aConfig;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1294,15 +1292,9 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleConfig) {
- $this->singleConfig->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleConfig instanceof PropelCollection) {
- $this->singleConfig->clearIterator();
- }
- $this->singleConfig = null;
+ $this->aConfig = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseConfigDescPeer.php b/core/lib/Thelia/Model/om/BaseConfigDescPeer.php
index 2836dd3f9..87950542f 100644
--- a/core/lib/Thelia/Model/om/BaseConfigDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseConfigDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseConfigDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'config_desc';
@@ -398,9 +398,6 @@ abstract class BaseConfigDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in ConfigPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ConfigPeer::clearInstancePool();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseConfigDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Config table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinConfig(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ConfigDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ConfigDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ConfigDescPeer::CONFIG_ID, ConfigPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ConfigDesc objects pre-filled with their Config objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ConfigDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinConfig(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME);
+ }
+
+ ConfigDescPeer::addSelectColumns($criteria);
+ $startcol = ConfigDescPeer::NUM_HYDRATE_COLUMNS;
+ ConfigPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ConfigDescPeer::CONFIG_ID, ConfigPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ConfigDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ConfigDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ConfigDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ConfigDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ConfigPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ConfigPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ConfigPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ConfigPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ConfigDesc) to $obj2 (Config)
+ $obj2->addConfigDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ConfigDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ConfigDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ConfigDescPeer::CONFIG_ID, ConfigPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ConfigDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ConfigDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME);
+ }
+
+ ConfigDescPeer::addSelectColumns($criteria);
+ $startcol2 = ConfigDescPeer::NUM_HYDRATE_COLUMNS;
+
+ ConfigPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ConfigPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ConfigDescPeer::CONFIG_ID, ConfigPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ConfigDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ConfigDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ConfigDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ConfigDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Config rows
+
+ $key2 = ConfigPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ConfigPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ConfigPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ConfigPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ConfigDesc) to the collection in $obj2 (Config)
+ $obj2->addConfigDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -630,7 +865,6 @@ abstract class BaseConfigDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ConfigDescPeer::doOnDeleteCascade(new Criteria(ConfigDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ConfigDescPeer::TABLE_NAME, $con, ConfigDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +898,24 @@ abstract class BaseConfigDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ConfigDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ConfigDesc) { // it's a model object
+ // invalidate the cache for this single object
+ ConfigDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ConfigDescPeer::DATABASE_NAME);
$criteria->add(ConfigDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ConfigDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,23 +928,6 @@ abstract class BaseConfigDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ConfigDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ConfigDescPeer::clearInstancePool();
- } elseif ($values instanceof ConfigDesc) { // it's a model object
- ConfigDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ConfigDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ConfigDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -712,39 +939,6 @@ abstract class BaseConfigDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ConfigDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Config objects
- $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
-
- $criteria->add(ConfigPeer::ID, $obj->getConfigId());
- $affectedRows += ConfigPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ConfigDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseConfigDescQuery.php b/core/lib/Thelia/Model/om/BaseConfigDescQuery.php
index e50ded43d..cf63e9603 100644
--- a/core/lib/Thelia/Model/om/BaseConfigDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseConfigDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseConfigDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ConfigDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ConfigDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -283,6 +283,8 @@ abstract class BaseConfigDescQuery extends ModelCriteria
* $query->filterByConfigId(array('min' => 12)); // WHERE config_id > 12
*
*
+ * @see filterByConfig()
+ *
* @param mixed $configId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +521,7 @@ abstract class BaseConfigDescQuery extends ModelCriteria
/**
* Filter the query by a related Config object
*
- * @param Config|PropelObjectCollection $config the related object to use as filter
+ * @param Config|PropelObjectCollection $config The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ConfigDescQuery The current query, for fluid interface
@@ -531,10 +533,12 @@ abstract class BaseConfigDescQuery extends ModelCriteria
return $this
->addUsingAlias(ConfigDescPeer::CONFIG_ID, $config->getId(), $comparison);
} elseif ($config instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useConfigQuery()
- ->filterByPrimaryKeys($config->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ConfigDescPeer::CONFIG_ID, $config->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByConfig() only accepts arguments of type Config or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseConfigPeer.php b/core/lib/Thelia/Model/om/BaseConfigPeer.php
index 371ca4fe9..fa800aedb 100644
--- a/core/lib/Thelia/Model/om/BaseConfigPeer.php
+++ b/core/lib/Thelia/Model/om/BaseConfigPeer.php
@@ -25,7 +25,7 @@ abstract class BaseConfigPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'config';
@@ -393,6 +393,9 @@ abstract class BaseConfigPeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in ConfigDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ConfigDescPeer::clearInstancePool();
}
/**
@@ -489,245 +492,6 @@ abstract class BaseConfigPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related ConfigDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinConfigDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ConfigPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ConfigPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ConfigPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ConfigPeer::ID, ConfigDescPeer::CONFIG_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Config objects pre-filled with their ConfigDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Config objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinConfigDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ConfigPeer::DATABASE_NAME);
- }
-
- ConfigPeer::addSelectColumns($criteria);
- $startcol = ConfigPeer::NUM_HYDRATE_COLUMNS;
- ConfigDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ConfigPeer::ID, ConfigDescPeer::CONFIG_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ConfigPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ConfigPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ConfigPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ConfigPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ConfigDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ConfigDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ConfigDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ConfigDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Config) to $obj2 (ConfigDesc)
- // one to one relationship
- $obj1->setConfigDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ConfigPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ConfigPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ConfigPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ConfigPeer::ID, ConfigDescPeer::CONFIG_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Config objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Config objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ConfigPeer::DATABASE_NAME);
- }
-
- ConfigPeer::addSelectColumns($criteria);
- $startcol2 = ConfigPeer::NUM_HYDRATE_COLUMNS;
-
- ConfigDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ConfigDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ConfigPeer::ID, ConfigDescPeer::CONFIG_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ConfigPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ConfigPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ConfigPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ConfigPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ConfigDesc rows
-
- $key2 = ConfigDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ConfigDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ConfigDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ConfigDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Config) to the collection in $obj2 (ConfigDesc)
- $obj1->setConfigDesc($obj2);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseConfigQuery.php b/core/lib/Thelia/Model/om/BaseConfigQuery.php
index 999c94a20..a4090b85e 100644
--- a/core/lib/Thelia/Model/om/BaseConfigQuery.php
+++ b/core/lib/Thelia/Model/om/BaseConfigQuery.php
@@ -76,7 +76,7 @@ abstract class BaseConfigQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Config', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Config', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -252,8 +252,6 @@ abstract class BaseConfigQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByConfigDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -500,7 +498,7 @@ abstract class BaseConfigQuery extends ModelCriteria
/**
* Filter the query by a related ConfigDesc object
*
- * @param ConfigDesc|PropelObjectCollection $configDesc The related object(s) to use as filter
+ * @param ConfigDesc|PropelObjectCollection $configDesc the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ConfigQuery The current query, for fluid interface
@@ -512,12 +510,10 @@ abstract class BaseConfigQuery extends ModelCriteria
return $this
->addUsingAlias(ConfigPeer::ID, $configDesc->getConfigId(), $comparison);
} elseif ($configDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ConfigPeer::ID, $configDesc->toKeyValue('PrimaryKey', 'ConfigId'), $comparison);
+ ->useConfigDescQuery()
+ ->filterByPrimaryKeys($configDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByConfigDesc() only accepts arguments of type ConfigDesc or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseContent.php b/core/lib/Thelia/Model/om/BaseContent.php
index 3959bf9ae..f5dce9a13 100644
--- a/core/lib/Thelia/Model/om/BaseContent.php
+++ b/core/lib/Thelia/Model/om/BaseContent.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Content;
use Thelia\Model\ContentAssoc;
@@ -88,34 +90,40 @@ abstract class BaseContent extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var ContentAssoc
+ * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects.
*/
- protected $aContentAssoc;
+ protected $collContentAssocs;
+ protected $collContentAssocsPartial;
/**
- * @var ContentDesc
+ * @var PropelObjectCollection|ContentDesc[] Collection to store aggregation of ContentDesc objects.
*/
- protected $aContentDesc;
+ protected $collContentDescs;
+ protected $collContentDescsPartial;
/**
- * @var ContentFolder
+ * @var PropelObjectCollection|ContentFolder[] Collection to store aggregation of ContentFolder objects.
*/
- protected $aContentFolder;
+ protected $collContentFolders;
+ protected $collContentFoldersPartial;
/**
- * @var Document
+ * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects.
*/
- protected $aDocument;
+ protected $collDocuments;
+ protected $collDocumentsPartial;
/**
- * @var Image
+ * @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects.
*/
- protected $aImage;
+ protected $collImages;
+ protected $collImagesPartial;
/**
- * @var Rewriting
+ * @var PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects.
*/
- protected $aRewriting;
+ protected $collRewritings;
+ protected $collRewritingsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -131,6 +139,42 @@ 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
+ */
+ protected $contentDescsScheduledForDeletion = null;
+
+ /**
+ * 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
+ */
+ protected $imagesScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $rewritingsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -252,30 +296,6 @@ abstract class BaseContent extends BaseObject implements Persistent
$this->modifiedColumns[] = ContentPeer::ID;
}
- if ($this->aContentAssoc !== null && $this->aContentAssoc->getContentId() !== $v) {
- $this->aContentAssoc = null;
- }
-
- if ($this->aContentDesc !== null && $this->aContentDesc->getContentId() !== $v) {
- $this->aContentDesc = null;
- }
-
- if ($this->aContentFolder !== null && $this->aContentFolder->getContentId() !== $v) {
- $this->aContentFolder = null;
- }
-
- if ($this->aDocument !== null && $this->aDocument->getContentId() !== $v) {
- $this->aDocument = null;
- }
-
- if ($this->aImage !== null && $this->aImage->getContentId() !== $v) {
- $this->aImage = null;
- }
-
- if ($this->aRewriting !== null && $this->aRewriting->getContentId() !== $v) {
- $this->aRewriting = null;
- }
-
return $this;
} // setId()
@@ -436,24 +456,6 @@ abstract class BaseContent extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aContentAssoc !== null && $this->id !== $this->aContentAssoc->getContentId()) {
- $this->aContentAssoc = null;
- }
- if ($this->aContentDesc !== null && $this->id !== $this->aContentDesc->getContentId()) {
- $this->aContentDesc = null;
- }
- if ($this->aContentFolder !== null && $this->id !== $this->aContentFolder->getContentId()) {
- $this->aContentFolder = null;
- }
- if ($this->aDocument !== null && $this->id !== $this->aDocument->getContentId()) {
- $this->aDocument = null;
- }
- if ($this->aImage !== null && $this->id !== $this->aImage->getContentId()) {
- $this->aImage = null;
- }
- if ($this->aRewriting !== null && $this->id !== $this->aRewriting->getContentId()) {
- $this->aRewriting = null;
- }
} // ensureConsistency
/**
@@ -493,12 +495,18 @@ abstract class BaseContent extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aContentAssoc = null;
- $this->aContentDesc = null;
- $this->aContentFolder = null;
- $this->aDocument = null;
- $this->aImage = null;
- $this->aRewriting = null;
+ $this->collContentAssocs = null;
+
+ $this->collContentDescs = null;
+
+ $this->collContentFolders = null;
+
+ $this->collDocuments = null;
+
+ $this->collImages = null;
+
+ $this->collRewritings = null;
+
} // if (deep)
}
@@ -612,53 +620,6 @@ abstract class BaseContent extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aContentAssoc !== null) {
- if ($this->aContentAssoc->isModified() || $this->aContentAssoc->isNew()) {
- $affectedRows += $this->aContentAssoc->save($con);
- }
- $this->setContentAssoc($this->aContentAssoc);
- }
-
- if ($this->aContentDesc !== null) {
- if ($this->aContentDesc->isModified() || $this->aContentDesc->isNew()) {
- $affectedRows += $this->aContentDesc->save($con);
- }
- $this->setContentDesc($this->aContentDesc);
- }
-
- if ($this->aContentFolder !== null) {
- if ($this->aContentFolder->isModified() || $this->aContentFolder->isNew()) {
- $affectedRows += $this->aContentFolder->save($con);
- }
- $this->setContentFolder($this->aContentFolder);
- }
-
- if ($this->aDocument !== null) {
- if ($this->aDocument->isModified() || $this->aDocument->isNew()) {
- $affectedRows += $this->aDocument->save($con);
- }
- $this->setDocument($this->aDocument);
- }
-
- if ($this->aImage !== null) {
- if ($this->aImage->isModified() || $this->aImage->isNew()) {
- $affectedRows += $this->aImage->save($con);
- }
- $this->setImage($this->aImage);
- }
-
- if ($this->aRewriting !== null) {
- if ($this->aRewriting->isModified() || $this->aRewriting->isNew()) {
- $affectedRows += $this->aRewriting->save($con);
- }
- $this->setRewriting($this->aRewriting);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -670,6 +631,112 @@ 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()
+ ->filterByPrimaryKeys($this->contentDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentDescs !== null) {
+ foreach ($this->collContentDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ 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->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->rewritingsScheduledForDeletion !== null) {
+ if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
+ foreach ($this->rewritingsScheduledForDeletion as $rewriting) {
+ // need to save related object because we set the relation to null
+ $rewriting->save($con);
+ }
+ $this->rewritingsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -831,53 +898,59 @@ abstract class BaseContent extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aContentAssoc !== null) {
- if (!$this->aContentAssoc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aContentAssoc->getValidationFailures());
- }
- }
-
- if ($this->aContentDesc !== null) {
- if (!$this->aContentDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aContentDesc->getValidationFailures());
- }
- }
-
- if ($this->aContentFolder !== null) {
- if (!$this->aContentFolder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aContentFolder->getValidationFailures());
- }
- }
-
- if ($this->aDocument !== null) {
- if (!$this->aDocument->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aDocument->getValidationFailures());
- }
- }
-
- if ($this->aImage !== null) {
- if (!$this->aImage->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aImage->getValidationFailures());
- }
- }
-
- if ($this->aRewriting !== null) {
- if (!$this->aRewriting->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aRewriting->getValidationFailures());
- }
- }
-
-
if (($retval = ContentPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ 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)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ 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->collImages !== null) {
+ foreach ($this->collImages 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)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -964,23 +1037,23 @@ abstract class BaseContent extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aContentAssoc) {
- $result['ContentAssoc'] = $this->aContentAssoc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aContentDesc) {
- $result['ContentDesc'] = $this->aContentDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collContentDescs) {
+ $result['ContentDescs'] = $this->collContentDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aContentFolder) {
- $result['ContentFolder'] = $this->aContentFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collContentFolders) {
+ $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aDocument) {
- $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aImage) {
- $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aRewriting) {
- $result['Rewriting'] = $this->aRewriting->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1151,34 +1224,40 @@ abstract class BaseContent extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getContentAssoc();
- if ($relObj) {
- $copyObj->setContentAssoc($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));
+ }
}
- $relObj = $this->getContentDesc();
- if ($relObj) {
- $copyObj->setContentDesc($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));
+ }
}
- $relObj = $this->getContentFolder();
- if ($relObj) {
- $copyObj->setContentFolder($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));
+ }
}
- $relObj = $this->getDocument();
- if ($relObj) {
- $copyObj->setDocument($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));
+ }
}
- $relObj = $this->getImage();
- if ($relObj) {
- $copyObj->setImage($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));
+ }
}
- $relObj = $this->getRewriting();
- if ($relObj) {
- $copyObj->setRewriting($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));
+ }
}
//unflag object copy
@@ -1231,286 +1310,1577 @@ abstract class BaseContent extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a ContentAssoc object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param ContentAssoc $v
- * @return Content The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ 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 ('Image' == $relationName) {
+ $this->initImages();
+ }
+ if ('Rewriting' == $relationName) {
+ $this->initRewritings();
+ }
+ }
+
+ /**
+ * 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 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|ContentAssoc[] List of ContentAssoc objects
* @throws PropelException
*/
- public function setContentAssoc(ContentAssoc $v = null)
+ public function getContentAssocs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByContent($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->setContent(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
+ ->filterByContent($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getContentId());
+ return count($this->collContentAssocs);
}
+ }
- $this->aContentAssoc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setContent($this);
+ /**
+ * Method called to associate a ContentAssoc object to this object
+ * through the ContentAssoc foreign key attribute.
+ *
+ * @param ContentAssoc $l ContentAssoc
+ * @return Content 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;
}
-
/**
- * Get the associated ContentAssoc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ContentAssoc The associated ContentAssoc object.
- * @throws PropelException
+ * @param ContentAssoc $contentAssoc The contentAssoc object to add.
*/
- public function getContentAssoc(PropelPDO $con = null)
+ protected function doAddContentAssoc($contentAssoc)
{
- if ($this->aContentAssoc === null && ($this->id !== null)) {
- $this->aContentAssoc = ContentAssocQuery::create()
- ->filterByContent($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aContentAssoc->setContent($this);
- }
-
- return $this->aContentAssoc;
+ $this->collContentAssocs[]= $contentAssoc;
+ $contentAssoc->setContent($this);
}
/**
- * Declares an association between this object and a ContentDesc object.
+ * @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->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 ContentAssocs from storage.
*
- * @param ContentDesc $v
- * @return Content The current object (for fluent API support)
+ * 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|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 Content is new, it will return
+ * an empty collection; or if this Content 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 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|ContentAssoc[] List of ContentAssoc objects
+ */
+ public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = ContentAssocQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ 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 setContentDesc(ContentDesc $v = null)
+ public function getContentDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getContentId());
+ return count($this->collContentDescs);
}
+ }
- $this->aContentDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setContent($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated ContentDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ContentDesc The associated ContentDesc object.
- * @throws PropelException
+ * @param ContentDesc $contentDesc The contentDesc object to add.
*/
- public function getContentDesc(PropelPDO $con = null)
+ protected function doAddContentDesc($contentDesc)
{
- if ($this->aContentDesc === null && ($this->id !== null)) {
- $this->aContentDesc = ContentDescQuery::create()
- ->filterByContent($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aContentDesc->setContent($this);
- }
-
- return $this->aContentDesc;
+ $this->collContentDescs[]= $contentDesc;
+ $contentDesc->setContent($this);
}
/**
- * Declares an association between this object and a ContentFolder object.
+ * @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
*
- * @param ContentFolder $v
- * @return Content The current object (for fluent API support)
+ * 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 setContentFolder(ContentFolder $v = null)
+ public function getContentFolders($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getContentId());
+ return count($this->collContentFolders);
}
+ }
- $this->aContentFolder = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setContent($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated ContentFolder object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ContentFolder The associated ContentFolder object.
- * @throws PropelException
+ * @param ContentFolder $contentFolder The contentFolder object to add.
*/
- public function getContentFolder(PropelPDO $con = null)
+ protected function doAddContentFolder($contentFolder)
{
- if ($this->aContentFolder === null && ($this->id !== null)) {
- $this->aContentFolder = ContentFolderQuery::create()
- ->filterByContent($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aContentFolder->setContent($this);
- }
-
- return $this->aContentFolder;
+ $this->collContentFolders[]= $contentFolder;
+ $contentFolder->setContent($this);
}
/**
- * Declares an association between this object and a Document object.
+ * @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.
*
- * @param Document $v
- * @return Content The current object (for fluent API support)
+ * 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 setDocument(Document $v = null)
+ public function getDocuments($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getContentId());
+ return count($this->collDocuments);
}
+ }
- $this->aDocument = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setContent($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated Document object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Document The associated Document object.
- * @throws PropelException
+ * @param Document $document The document object to add.
*/
- public function getDocument(PropelPDO $con = null)
+ protected function doAddDocument($document)
{
- if ($this->aDocument === null && ($this->id !== null)) {
- $this->aDocument = DocumentQuery::create()
- ->filterByContent($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aDocument->setContent($this);
- }
-
- return $this->aDocument;
+ $this->collDocuments[]= $document;
+ $document->setContent($this);
}
/**
- * Declares an association between this object and a Image object.
+ * @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.
*
- * @param Image $v
- * @return Content The current object (for fluent API support)
+ * 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
+ *
+ * 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 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|Image[] List of Image objects
* @throws PropelException
*/
- public function setImage(Image $v = null)
+ public function getImages($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByContent($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->setContent(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
+ ->filterByContent($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getContentId());
+ return count($this->collImages);
}
+ }
- $this->aImage = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setContent($this);
+ /**
+ * Method called to associate a Image object to this object
+ * through the Image foreign key attribute.
+ *
+ * @param Image $l Image
+ * @return Content 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;
}
-
/**
- * Get the associated Image object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Image The associated Image object.
- * @throws PropelException
+ * @param Image $image The image object to add.
*/
- public function getImage(PropelPDO $con = null)
+ protected function doAddImage($image)
{
- if ($this->aImage === null && ($this->id !== null)) {
- $this->aImage = ImageQuery::create()
- ->filterByContent($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aImage->setContent($this);
- }
-
- return $this->aImage;
+ $this->collImages[]= $image;
+ $image->setContent($this);
}
/**
- * Declares an association between this object and a Rewriting object.
+ * @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->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 Images from storage.
*
- * @param Rewriting $v
- * @return Content The current object (for fluent API support)
+ * 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|Image[] List of Image objects
+ */
+ public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = ImageQuery::create(null, $criteria);
+ $query->joinWith('Product', $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 Content is new, it will return
+ * an empty collection; or if this Content 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 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|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 Content is new, it will return
+ * an empty collection; or if this Content 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 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|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 collRewritings 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 addRewritings()
+ */
+ public function clearRewritings()
+ {
+ $this->collRewritings = null; // important to set this to null since that means it is uninitialized
+ $this->collRewritingsPartial = null;
+ }
+
+ /**
+ * reset is the collRewritings collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialRewritings($v = true)
+ {
+ $this->collRewritingsPartial = $v;
+ }
+
+ /**
+ * Initializes the collRewritings collection.
+ *
+ * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
+ * 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 initRewritings($overrideExisting = true)
+ {
+ if (null !== $this->collRewritings && !$overrideExisting) {
+ return;
+ }
+ $this->collRewritings = new PropelObjectCollection();
+ $this->collRewritings->setModel('Rewriting');
+ }
+
+ /**
+ * Gets an array of Rewriting 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|Rewriting[] List of Rewriting objects
* @throws PropelException
*/
- public function setRewriting(Rewriting $v = null)
+ public function getRewritings($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ // return empty collection
+ $this->initRewritings();
+ } else {
+ $collRewritings = RewritingQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collRewritingsPartial && count($collRewritings)) {
+ $this->initRewritings(false);
+
+ foreach($collRewritings as $obj) {
+ if (false == $this->collRewritings->contains($obj)) {
+ $this->collRewritings->append($obj);
+ }
+ }
+
+ $this->collRewritingsPartial = true;
+ }
+
+ return $collRewritings;
+ }
+
+ if($partial && $this->collRewritings) {
+ foreach($this->collRewritings as $obj) {
+ if($obj->isNew()) {
+ $collRewritings[] = $obj;
+ }
+ }
+ }
+
+ $this->collRewritings = $collRewritings;
+ $this->collRewritingsPartial = false;
+ }
+ }
+
+ return $this->collRewritings;
+ }
+
+ /**
+ * Sets a collection of Rewriting 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 $rewritings A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
+ {
+ $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
+
+ foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) {
+ $rewritingRemoved->setContent(null);
+ }
+
+ $this->collRewritings = null;
+ foreach ($rewritings as $rewriting) {
+ $this->addRewriting($rewriting);
+ }
+
+ $this->collRewritings = $rewritings;
+ $this->collRewritingsPartial = false;
+ }
+
+ /**
+ * Returns the number of related Rewriting objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Rewriting objects.
+ * @throws PropelException
+ */
+ public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getRewritings());
+ }
+ $query = RewritingQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getContentId());
+ return count($this->collRewritings);
}
+ }
- $this->aRewriting = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setContent($this);
+ /**
+ * Method called to associate a Rewriting object to this object
+ * through the Rewriting foreign key attribute.
+ *
+ * @param Rewriting $l Rewriting
+ * @return Content The current object (for fluent API support)
+ */
+ public function addRewriting(Rewriting $l)
+ {
+ if ($this->collRewritings === null) {
+ $this->initRewritings();
+ $this->collRewritingsPartial = true;
+ }
+ if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddRewriting($l);
}
-
return $this;
}
+ /**
+ * @param Rewriting $rewriting The rewriting object to add.
+ */
+ protected function doAddRewriting($rewriting)
+ {
+ $this->collRewritings[]= $rewriting;
+ $rewriting->setContent($this);
+ }
/**
- * Get the associated Rewriting object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Rewriting The associated Rewriting object.
- * @throws PropelException
+ * @param Rewriting $rewriting The rewriting object to remove.
*/
- public function getRewriting(PropelPDO $con = null)
+ public function removeRewriting($rewriting)
{
- if ($this->aRewriting === null && ($this->id !== null)) {
- $this->aRewriting = RewritingQuery::create()
- ->filterByContent($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aRewriting->setContent($this);
+ if ($this->getRewritings()->contains($rewriting)) {
+ $this->collRewritings->remove($this->collRewritings->search($rewriting));
+ if (null === $this->rewritingsScheduledForDeletion) {
+ $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
+ $this->rewritingsScheduledForDeletion->clear();
+ }
+ $this->rewritingsScheduledForDeletion[]= $rewriting;
+ $rewriting->setContent(null);
}
+ }
- return $this->aRewriting;
+
+ /**
+ * 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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getRewritings($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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Category', $join_behavior);
+
+ return $this->getRewritings($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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Folder', $join_behavior);
+
+ return $this->getRewritings($query, $con);
}
/**
@@ -1543,14 +2913,62 @@ 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) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collImages) {
+ foreach ($this->collImages as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collRewritings) {
+ foreach ($this->collRewritings as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aContentAssoc = null;
- $this->aContentDesc = null;
- $this->aContentFolder = null;
- $this->aDocument = null;
- $this->aImage = null;
- $this->aRewriting = null;
+ 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();
+ }
+ $this->collContentFolders = null;
+ if ($this->collDocuments instanceof PropelCollection) {
+ $this->collDocuments->clearIterator();
+ }
+ $this->collDocuments = null;
+ if ($this->collImages instanceof PropelCollection) {
+ $this->collImages->clearIterator();
+ }
+ $this->collImages = null;
+ if ($this->collRewritings instanceof PropelCollection) {
+ $this->collRewritings->clearIterator();
+ }
+ $this->collRewritings = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseContentAssoc.php b/core/lib/Thelia/Model/om/BaseContentAssoc.php
index 9fdf78c41..c98102990 100644
--- a/core/lib/Thelia/Model/om/BaseContentAssoc.php
+++ b/core/lib/Thelia/Model/om/BaseContentAssoc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Category;
use Thelia\Model\CategoryQuery;
@@ -96,19 +94,19 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Category one-to-one related Category object
+ * @var Category
*/
- protected $singleCategory;
+ protected $aCategory;
/**
- * @var Content one-to-one related Content object
+ * @var Product
*/
- protected $singleContent;
+ protected $aProduct;
/**
- * @var Product one-to-one related Product object
+ * @var Content
*/
- protected $singleProduct;
+ protected $aContent;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -124,24 +122,6 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $categorysScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $contentsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -304,6 +284,10 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
$this->modifiedColumns[] = ContentAssocPeer::CATEGORY_ID;
}
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
return $this;
} // setCategoryId()
@@ -325,6 +309,10 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
$this->modifiedColumns[] = ContentAssocPeer::PRODUCT_ID;
}
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
return $this;
} // setProductId()
@@ -346,6 +334,10 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
$this->modifiedColumns[] = ContentAssocPeer::CONTENT_ID;
}
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
return $this;
} // setContentId()
@@ -487,6 +479,15 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
} // ensureConsistency
/**
@@ -526,12 +527,9 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCategory = null;
-
- $this->singleContent = null;
-
- $this->singleProduct = null;
-
+ $this->aCategory = null;
+ $this->aProduct = null;
+ $this->aContent = null;
} // if (deep)
}
@@ -645,6 +643,32 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -656,51 +680,6 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->categorysScheduledForDeletion !== null) {
- if (!$this->categorysScheduledForDeletion->isEmpty()) {
- CategoryQuery::create()
- ->filterByPrimaryKeys($this->categorysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->categorysScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->isDeleted()) {
- $affectedRows += $this->singleCategory->save($con);
- }
- }
-
- if ($this->contentsScheduledForDeletion !== null) {
- if (!$this->contentsScheduledForDeletion->isEmpty()) {
- ContentQuery::create()
- ->filterByPrimaryKeys($this->contentsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->contentsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->isDeleted()) {
- $affectedRows += $this->singleContent->save($con);
- }
- }
-
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -874,29 +853,35 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+ if ($this->aProduct !== null) {
+ if (!$this->aProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
+ }
+ }
+
+ if ($this->aContent !== null) {
+ if (!$this->aContent->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures());
+ }
+ }
+
+
if (($retval = ContentAssocPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCategory->getValidationFailures());
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleContent->getValidationFailures());
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -991,14 +976,14 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCategory) {
- $result['Category'] = $this->singleCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleContent) {
- $result['Content'] = $this->singleContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1181,21 +1166,6 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCategory();
- if ($relObj) {
- $copyObj->setCategory($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getContent();
- if ($relObj) {
- $copyObj->setContent($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1246,127 +1216,159 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Category object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Category object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Category
- * @throws PropelException
- */
- public function getCategory(PropelPDO $con = null)
- {
-
- if ($this->singleCategory === null && !$this->isNew()) {
- $this->singleCategory = CategoryQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCategory;
- }
-
- /**
- * Sets a single Category object as related to this object by a one-to-one relationship.
- *
- * @param Category $v Category
+ * @param Category $v
* @return ContentAssoc The current object (for fluent API support)
* @throws PropelException
*/
public function setCategory(Category $v = null)
{
- $this->singleCategory = $v;
-
- // Make sure that that the passed-in Category isn't already associated with this object
- if ($v !== null && $v->getContentAssoc() === null) {
- $v->setContentAssoc($this);
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
}
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Category object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentAssoc($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Content object, which is related to this object by a one-to-one relationship.
+ * Get the associated Category object
*
- * @param PropelPDO $con optional connection object
- * @return Content
+ * @param PropelPDO $con Optional Connection object.
+ * @return Category The associated Category object.
* @throws PropelException
*/
- public function getContent(PropelPDO $con = null)
+ public function getCategory(PropelPDO $con = null)
{
-
- if ($this->singleContent === null && !$this->isNew()) {
- $this->singleContent = ContentQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->category_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->aCategory->addContentAssocs($this);
+ */
}
- return $this->singleContent;
+ return $this->aCategory;
}
/**
- * Sets a single Content object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Product object.
*
- * @param Content $v Content
- * @return ContentAssoc The current object (for fluent API support)
- * @throws PropelException
- */
- public function setContent(Content $v = null)
- {
- $this->singleContent = $v;
-
- // Make sure that that the passed-in Content isn't already associated with this object
- if ($v !== null && $v->getContentAssoc() === null) {
- $v->setContentAssoc($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Product
- * @throws PropelException
- */
- public function getProduct(PropelPDO $con = null)
- {
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleProduct;
- }
-
- /**
- * Sets a single Product object as related to this object by a one-to-one relationship.
- *
- * @param Product $v Product
+ * @param Product $v
* @return ContentAssoc The current object (for fluent API support)
* @throws PropelException
*/
public function setProduct(Product $v = null)
{
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getContentAssoc() === null) {
- $v->setContentAssoc($this);
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
}
+ $this->aProduct = $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 ($v !== null) {
+ $v->addContentAssoc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Product object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
+ * @throws PropelException
+ */
+ public function getProduct(PropelPDO $con = null)
+ {
+ 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->aProduct->addContentAssocs($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a Content object.
+ *
+ * @param Content $v
+ * @return ContentAssoc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(Content $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Content object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentAssoc($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Content object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Content The associated Content object.
+ * @throws PropelException
+ */
+ public function getContent(PropelPDO $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ContentQuery::create()->findPk($this->content_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->aContent->addContentAssocs($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1399,29 +1401,11 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCategory) {
- $this->singleCategory->clearAllReferences($deep);
- }
- if ($this->singleContent) {
- $this->singleContent->clearAllReferences($deep);
- }
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCategory instanceof PropelCollection) {
- $this->singleCategory->clearIterator();
- }
- $this->singleCategory = null;
- if ($this->singleContent instanceof PropelCollection) {
- $this->singleContent->clearIterator();
- }
- $this->singleContent = null;
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
+ $this->aCategory = null;
+ $this->aProduct = null;
+ $this->aContent = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseContentAssocPeer.php b/core/lib/Thelia/Model/om/BaseContentAssocPeer.php
index 9f657c5b3..637af73d2 100644
--- a/core/lib/Thelia/Model/om/BaseContentAssocPeer.php
+++ b/core/lib/Thelia/Model/om/BaseContentAssocPeer.php
@@ -27,7 +27,7 @@ abstract class BaseContentAssocPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'content_assoc';
@@ -395,15 +395,6 @@ abstract class BaseContentAssocPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CategoryPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CategoryPeer::clearInstancePool();
- // Invalidate objects in ContentPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ContentPeer::clearInstancePool();
- // Invalidate objects in ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
}
/**
@@ -500,6 +491,983 @@ abstract class BaseContentAssocPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentAssocPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentAssocPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentAssocPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ContentAssoc objects pre-filled with their Category objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentAssoc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+ }
+
+ ContentAssocPeer::addSelectColumns($criteria);
+ $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ContentAssocPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentAssocPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ContentAssoc) to $obj2 (Category)
+ $obj2->addContentAssoc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of ContentAssoc 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
+ * @return array Array of ContentAssoc objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+ }
+
+ ContentAssocPeer::addSelectColumns($criteria);
+ $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ContentAssocPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentAssocPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ContentAssoc) to $obj2 (Product)
+ $obj2->addContentAssoc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of ContentAssoc objects pre-filled with their Content objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentAssoc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+ }
+
+ ContentAssocPeer::addSelectColumns($criteria);
+ $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
+ ContentPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ContentAssocPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentAssocPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ContentAssoc) to $obj2 (Content)
+ $obj2->addContentAssoc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentAssocPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ContentAssoc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentAssoc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+ }
+
+ ContentAssocPeer::addSelectColumns($criteria);
+ $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentAssocPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentAssocPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category)
+ $obj2->addContentAssoc($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Product rows
+
+ $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ProductPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ProductPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Product)
+ $obj3->addContentAssoc($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Content rows
+
+ $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ContentPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ContentPeer::addInstanceToPool($obj4, $key4);
+ } // if obj4 loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj4 (Content)
+ $obj4->addContentAssoc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentAssocPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentAssocPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentAssocPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ContentAssoc objects pre-filled with all related objects except Category.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentAssoc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+ }
+
+ ContentAssocPeer::addSelectColumns($criteria);
+ $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentAssocPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentAssocPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Product)
+ $obj2->addContentAssoc($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ContentPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ContentPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Content)
+ $obj3->addContentAssoc($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of ContentAssoc objects pre-filled with all related objects except Product.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentAssoc objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+ }
+
+ ContentAssocPeer::addSelectColumns($criteria);
+ $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentAssocPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentAssocPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category)
+ $obj2->addContentAssoc($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ContentPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ContentPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Content)
+ $obj3->addContentAssoc($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of ContentAssoc objects pre-filled with all related objects except Content.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentAssoc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+ }
+
+ ContentAssocPeer::addSelectColumns($criteria);
+ $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentAssocPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentAssocPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category)
+ $obj2->addContentAssoc($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Product rows
+
+ $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ProductPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ProductPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Product)
+ $obj3->addContentAssoc($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -633,7 +1601,6 @@ abstract class BaseContentAssocPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ContentAssocPeer::doOnDeleteCascade(new Criteria(ContentAssocPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ContentAssocPeer::TABLE_NAME, $con, ContentAssocPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -667,14 +1634,24 @@ abstract class BaseContentAssocPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ContentAssocPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ContentAssoc) { // it's a model object
+ // invalidate the cache for this single object
+ ContentAssocPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
$criteria->add(ContentAssocPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ContentAssocPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -687,23 +1664,6 @@ abstract class BaseContentAssocPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ContentAssocPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ContentAssocPeer::clearInstancePool();
- } elseif ($values instanceof ContentAssoc) { // it's a model object
- ContentAssocPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ContentAssocPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ContentAssocPeer::clearRelatedInstancePool();
$con->commit();
@@ -715,51 +1675,6 @@ abstract class BaseContentAssocPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ContentAssocPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Category objects
- $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
-
- $criteria->add(CategoryPeer::ID, $obj->getCategoryId());
- $affectedRows += CategoryPeer::doDelete($criteria, $con);
-
- // delete related Content objects
- $criteria = new Criteria(ContentPeer::DATABASE_NAME);
-
- $criteria->add(ContentPeer::ID, $obj->getContentId());
- $affectedRows += ContentPeer::doDelete($criteria, $con);
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ContentAssoc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php
index 8df9310e9..d36c9216c 100644
--- a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php
+++ b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php
@@ -48,14 +48,14 @@ use Thelia\Model\Product;
* @method ContentAssocQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
* @method ContentAssocQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation
*
- * @method ContentAssocQuery leftJoinContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the Content relation
- * @method ContentAssocQuery rightJoinContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Content relation
- * @method ContentAssocQuery innerJoinContent($relationAlias = null) Adds a INNER JOIN clause to the query using the Content relation
- *
* @method ContentAssocQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
* @method ContentAssocQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
* @method ContentAssocQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
*
+ * @method ContentAssocQuery leftJoinContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the Content relation
+ * @method ContentAssocQuery rightJoinContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Content relation
+ * @method ContentAssocQuery innerJoinContent($relationAlias = null) Adds a INNER JOIN clause to the query using the Content relation
+ *
* @method ContentAssoc findOne(PropelPDO $con = null) Return the first ContentAssoc matching the query
* @method ContentAssoc findOneOrCreate(PropelPDO $con = null) Return the first ContentAssoc matching the query, or a new ContentAssoc object populated from the query conditions when no match is found
*
@@ -86,7 +86,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ContentAssoc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ContentAssoc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -289,6 +289,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
*
*
+ * @see filterByCategory()
+ *
* @param mixed $categoryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -330,6 +332,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProduct()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -371,6 +375,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria
* $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
*
*
+ * @see filterByContent()
+ *
* @param mixed $contentId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -532,7 +538,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria
/**
* Filter the query by a related Category object
*
- * @param Category|PropelObjectCollection $category the related object to use as filter
+ * @param Category|PropelObjectCollection $category The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ContentAssocQuery The current query, for fluid interface
@@ -544,10 +550,12 @@ abstract class BaseContentAssocQuery extends ModelCriteria
return $this
->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $category->getId(), $comparison);
} elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCategoryQuery()
- ->filterByPrimaryKeys($category->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
}
@@ -561,7 +569,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria
*
* @return ContentAssocQuery The current query, for fluid interface
*/
- public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Category');
@@ -596,91 +604,17 @@ abstract class BaseContentAssocQuery extends ModelCriteria
*
* @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
*/
- public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinCategory($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
}
- /**
- * Filter the query by a related Content object
- *
- * @param Content|PropelObjectCollection $content the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ContentAssocQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByContent($content, $comparison = null)
- {
- if ($content instanceof Content) {
- return $this
- ->addUsingAlias(ContentAssocPeer::CONTENT_ID, $content->getId(), $comparison);
- } elseif ($content instanceof PropelObjectCollection) {
- return $this
- ->useContentQuery()
- ->filterByPrimaryKeys($content->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Content relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return ContentAssocQuery The current query, for fluid interface
- */
- public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Content');
-
- // 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, 'Content');
- }
-
- return $this;
- }
-
- /**
- * Use the Content relation Content 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\ContentQuery A secondary query class using the current class as primary query
- */
- public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinContent($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
- }
-
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product the related object 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 ContentAssocQuery The current query, for fluid interface
@@ -692,10 +626,12 @@ abstract class BaseContentAssocQuery extends ModelCriteria
return $this
->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
}
@@ -709,7 +645,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria
*
* @return ContentAssocQuery The current query, for fluid interface
*/
- public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Product');
@@ -744,13 +680,89 @@ abstract class BaseContentAssocQuery extends ModelCriteria
*
* @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
*/
- public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinProduct($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
}
+ /**
+ * Filter the query by a related Content object
+ *
+ * @param Content|PropelObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof Content) {
+ return $this
+ ->addUsingAlias(ContentAssocPeer::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentAssocPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // 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, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content 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\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseContentDesc.php b/core/lib/Thelia/Model/om/BaseContentDesc.php
index 71c6a8a13..decccecc6 100644
--- a/core/lib/Thelia/Model/om/BaseContentDesc.php
+++ b/core/lib/Thelia/Model/om/BaseContentDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Content;
use Thelia\Model\ContentDesc;
@@ -104,9 +102,9 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Content one-to-one related Content object
+ * @var Content
*/
- protected $singleContent;
+ protected $aContent;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -122,12 +120,6 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $contentsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -310,6 +302,10 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = ContentDescPeer::CONTENT_ID;
}
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
return $this;
} // setContentId()
@@ -537,6 +533,9 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
} // ensureConsistency
/**
@@ -576,8 +575,7 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleContent = null;
-
+ $this->aContent = null;
} // if (deep)
}
@@ -691,6 +689,18 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -702,21 +712,6 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->contentsScheduledForDeletion !== null) {
- if (!$this->contentsScheduledForDeletion->isEmpty()) {
- ContentQuery::create()
- ->filterByPrimaryKeys($this->contentsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->contentsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->isDeleted()) {
- $affectedRows += $this->singleContent->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -902,17 +897,23 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aContent !== null) {
+ if (!$this->aContent->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures());
+ }
+ }
+
+
if (($retval = ContentDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleContent !== null) {
- if (!$this->singleContent->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleContent->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -1015,8 +1016,8 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
$keys[8] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleContent) {
- $result['Content'] = $this->singleContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1211,11 +1212,6 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getContent();
- if ($relObj) {
- $copyObj->setContent($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1266,55 +1262,57 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Content object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Content object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Content
- * @throws PropelException
- */
- public function getContent(PropelPDO $con = null)
- {
-
- if ($this->singleContent === null && !$this->isNew()) {
- $this->singleContent = ContentQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleContent;
- }
-
- /**
- * Sets a single Content object as related to this object by a one-to-one relationship.
- *
- * @param Content $v Content
+ * @param Content $v
* @return ContentDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setContent(Content $v = null)
{
- $this->singleContent = $v;
-
- // Make sure that that the passed-in Content isn't already associated with this object
- if ($v !== null && $v->getContentDesc() === null) {
- $v->setContentDesc($this);
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
}
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Content object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Content object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Content The associated Content object.
+ * @throws PropelException
+ */
+ public function getContent(PropelPDO $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ContentQuery::create()->findPk($this->content_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->aContent->addContentDescs($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1349,15 +1347,9 @@ abstract class BaseContentDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleContent) {
- $this->singleContent->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleContent instanceof PropelCollection) {
- $this->singleContent->clearIterator();
- }
- $this->singleContent = null;
+ $this->aContent = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseContentDescPeer.php b/core/lib/Thelia/Model/om/BaseContentDescPeer.php
index 292d7921d..4af41a9fd 100644
--- a/core/lib/Thelia/Model/om/BaseContentDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseContentDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseContentDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'content_desc';
@@ -403,9 +403,6 @@ abstract class BaseContentDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in ContentPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ContentPeer::clearInstancePool();
}
/**
@@ -502,6 +499,244 @@ abstract class BaseContentDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentDescPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ContentDesc objects pre-filled with their Content objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME);
+ }
+
+ ContentDescPeer::addSelectColumns($criteria);
+ $startcol = ContentDescPeer::NUM_HYDRATE_COLUMNS;
+ ContentPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ContentDescPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ContentDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ContentDesc) to $obj2 (Content)
+ $obj2->addContentDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentDescPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ContentDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME);
+ }
+
+ ContentDescPeer::addSelectColumns($criteria);
+ $startcol2 = ContentDescPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentDescPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Content rows
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ContentDesc) to the collection in $obj2 (Content)
+ $obj2->addContentDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -635,7 +870,6 @@ abstract class BaseContentDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ContentDescPeer::doOnDeleteCascade(new Criteria(ContentDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ContentDescPeer::TABLE_NAME, $con, ContentDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -669,14 +903,24 @@ abstract class BaseContentDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ContentDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ContentDesc) { // it's a model object
+ // invalidate the cache for this single object
+ ContentDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ContentDescPeer::DATABASE_NAME);
$criteria->add(ContentDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ContentDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -689,23 +933,6 @@ abstract class BaseContentDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ContentDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ContentDescPeer::clearInstancePool();
- } elseif ($values instanceof ContentDesc) { // it's a model object
- ContentDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ContentDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ContentDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -717,39 +944,6 @@ abstract class BaseContentDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ContentDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Content objects
- $criteria = new Criteria(ContentPeer::DATABASE_NAME);
-
- $criteria->add(ContentPeer::ID, $obj->getContentId());
- $affectedRows += ContentPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ContentDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseContentDescQuery.php b/core/lib/Thelia/Model/om/BaseContentDescQuery.php
index 906707535..4e78ae8e9 100644
--- a/core/lib/Thelia/Model/om/BaseContentDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseContentDescQuery.php
@@ -84,7 +84,7 @@ abstract class BaseContentDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ContentDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ContentDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -287,6 +287,8 @@ abstract class BaseContentDescQuery extends ModelCriteria
* $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
*
*
+ * @see filterByContent()
+ *
* @param mixed $contentId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -552,7 +554,7 @@ abstract class BaseContentDescQuery extends ModelCriteria
/**
* Filter the query by a related Content object
*
- * @param Content|PropelObjectCollection $content the related object to use as filter
+ * @param Content|PropelObjectCollection $content The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ContentDescQuery The current query, for fluid interface
@@ -564,10 +566,12 @@ abstract class BaseContentDescQuery extends ModelCriteria
return $this
->addUsingAlias(ContentDescPeer::CONTENT_ID, $content->getId(), $comparison);
} elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useContentQuery()
- ->filterByPrimaryKeys($content->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ContentDescPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseContentFolder.php b/core/lib/Thelia/Model/om/BaseContentFolder.php
index e8e93d61d..83fe4363c 100644
--- a/core/lib/Thelia/Model/om/BaseContentFolder.php
+++ b/core/lib/Thelia/Model/om/BaseContentFolder.php
@@ -9,9 +9,7 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Content;
use Thelia\Model\ContentFolder;
@@ -62,14 +60,14 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
protected $folder_id;
/**
- * @var Content one-to-one related Content object
+ * @var Content
*/
- protected $singleContent;
+ protected $aContent;
/**
- * @var Folder one-to-one related Folder object
+ * @var Folder
*/
- protected $singleFolder;
+ protected $aFolder;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -85,18 +83,6 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $contentsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $foldersScheduledForDeletion = null;
-
/**
* Get the [content_id] column value.
*
@@ -134,6 +120,10 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
$this->modifiedColumns[] = ContentFolderPeer::CONTENT_ID;
}
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
return $this;
} // setContentId()
@@ -155,6 +145,10 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
$this->modifiedColumns[] = ContentFolderPeer::FOLDER_ID;
}
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
return $this;
} // setFolderId()
@@ -224,6 +218,12 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
} // ensureConsistency
/**
@@ -263,10 +263,8 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleContent = null;
-
- $this->singleFolder = null;
-
+ $this->aContent = null;
+ $this->aFolder = null;
} // if (deep)
}
@@ -380,6 +378,25 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -391,36 +408,6 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->contentsScheduledForDeletion !== null) {
- if (!$this->contentsScheduledForDeletion->isEmpty()) {
- ContentQuery::create()
- ->filterByPrimaryKeys($this->contentsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->contentsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->isDeleted()) {
- $affectedRows += $this->singleContent->save($con);
- }
- }
-
- if ($this->foldersScheduledForDeletion !== null) {
- if (!$this->foldersScheduledForDeletion->isEmpty()) {
- FolderQuery::create()
- ->filterByPrimaryKeys($this->foldersScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->foldersScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->isDeleted()) {
- $affectedRows += $this->singleFolder->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -553,23 +540,29 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aContent !== null) {
+ if (!$this->aContent->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures());
+ }
+ }
+
+ if ($this->aFolder !== null) {
+ if (!$this->aFolder->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures());
+ }
+ }
+
+
if (($retval = ContentFolderPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleContent !== null) {
- if (!$this->singleContent->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleContent->getValidationFailures());
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFolder->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -644,11 +637,11 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
$keys[1] => $this->getFolderId(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleContent) {
- $result['Content'] = $this->singleContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleFolder) {
- $result['Folder'] = $this->singleFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -809,16 +802,6 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getContent();
- if ($relObj) {
- $copyObj->setContent($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getFolder();
- if ($relObj) {
- $copyObj->setFolder($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -868,91 +851,108 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Content object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Content object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Content
- * @throws PropelException
- */
- public function getContent(PropelPDO $con = null)
- {
-
- if ($this->singleContent === null && !$this->isNew()) {
- $this->singleContent = ContentQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleContent;
- }
-
- /**
- * Sets a single Content object as related to this object by a one-to-one relationship.
- *
- * @param Content $v Content
+ * @param Content $v
* @return ContentFolder The current object (for fluent API support)
* @throws PropelException
*/
public function setContent(Content $v = null)
{
- $this->singleContent = $v;
-
- // Make sure that that the passed-in Content isn't already associated with this object
- if ($v !== null && $v->getContentFolder() === null) {
- $v->setContentFolder($this);
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
}
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Content object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentFolder($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Folder object, which is related to this object by a one-to-one relationship.
+ * Get the associated Content object
*
- * @param PropelPDO $con optional connection object
- * @return Folder
+ * @param PropelPDO $con Optional Connection object.
+ * @return Content The associated Content object.
* @throws PropelException
*/
- public function getFolder(PropelPDO $con = null)
+ public function getContent(PropelPDO $con = null)
{
-
- if ($this->singleFolder === null && !$this->isNew()) {
- $this->singleFolder = FolderQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ContentQuery::create()->findPk($this->content_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->aContent->addContentFolders($this);
+ */
}
- return $this->singleFolder;
+ return $this->aContent;
}
/**
- * Sets a single Folder object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Folder object.
*
- * @param Folder $v Folder
+ * @param Folder $v
* @return ContentFolder The current object (for fluent API support)
* @throws PropelException
*/
public function setFolder(Folder $v = null)
{
- $this->singleFolder = $v;
-
- // Make sure that that the passed-in Folder isn't already associated with this object
- if ($v !== null && $v->getContentFolder() === null) {
- $v->setContentFolder($this);
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
}
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Folder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentFolder($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Folder object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Folder The associated Folder object.
+ * @throws PropelException
+ */
+ public function getFolder(PropelPDO $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = FolderQuery::create()->findPk($this->folder_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->aFolder->addContentFolders($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -980,22 +980,10 @@ abstract class BaseContentFolder extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleContent) {
- $this->singleContent->clearAllReferences($deep);
- }
- if ($this->singleFolder) {
- $this->singleFolder->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleContent instanceof PropelCollection) {
- $this->singleContent->clearIterator();
- }
- $this->singleContent = null;
- if ($this->singleFolder instanceof PropelCollection) {
- $this->singleFolder->clearIterator();
- }
- $this->singleFolder = null;
+ $this->aContent = null;
+ $this->aFolder = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php
index 7dfcb373d..d0168ded1 100644
--- a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php
+++ b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php
@@ -26,7 +26,7 @@ abstract class BaseContentFolderPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'content_folder';
@@ -369,12 +369,6 @@ abstract class BaseContentFolderPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in ContentPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ContentPeer::clearInstancePool();
- // Invalidate objects in FolderPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FolderPeer::clearInstancePool();
}
/**
@@ -471,6 +465,637 @@ abstract class BaseContentFolderPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentFolderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentFolderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ContentFolder objects pre-filled with their Content objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentFolder objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+ }
+
+ ContentFolderPeer::addSelectColumns($criteria);
+ $startcol = ContentFolderPeer::NUM_HYDRATE_COLUMNS;
+ ContentPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ContentFolderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentFolderPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ContentFolder) to $obj2 (Content)
+ $obj2->addContentFolder($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of ContentFolder objects pre-filled with their Folder objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentFolder objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+ }
+
+ ContentFolderPeer::addSelectColumns($criteria);
+ $startcol = ContentFolderPeer::NUM_HYDRATE_COLUMNS;
+ FolderPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ContentFolderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentFolderPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FolderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FolderPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ContentFolder) to $obj2 (Folder)
+ $obj2->addContentFolder($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentFolderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ContentFolder objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentFolder objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+ }
+
+ ContentFolderPeer::addSelectColumns($criteria);
+ $startcol2 = ContentFolderPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentFolderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentFolderPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Content rows
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ContentFolder) to the collection in $obj2 (Content)
+ $obj2->addContentFolder($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Folder rows
+
+ $key3 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = FolderPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ FolderPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (ContentFolder) to the collection in $obj3 (Folder)
+ $obj3->addContentFolder($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentFolderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentFolderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ContentFolder objects pre-filled with all related objects except Content.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentFolder objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+ }
+
+ ContentFolderPeer::addSelectColumns($criteria);
+ $startcol2 = ContentFolderPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentFolderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentFolderPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Folder rows
+
+ $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FolderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FolderPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (ContentFolder) to the collection in $obj2 (Folder)
+ $obj2->addContentFolder($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of ContentFolder objects pre-filled with all related objects except Folder.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ContentFolder objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+ }
+
+ ContentFolderPeer::addSelectColumns($criteria);
+ $startcol2 = ContentFolderPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentFolderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentFolderPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Content rows
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (ContentFolder) to the collection in $obj2 (Content)
+ $obj2->addContentFolder($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -608,7 +1233,6 @@ abstract class BaseContentFolderPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ContentFolderPeer::doOnDeleteCascade(new Criteria(ContentFolderPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ContentFolderPeer::TABLE_NAME, $con, ContentFolderPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -642,9 +1266,15 @@ abstract class BaseContentFolderPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ContentFolderPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ContentFolder) { // it's a model object
+ // invalidate the cache for this single object
+ ContentFolderPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
@@ -659,6 +1289,8 @@ abstract class BaseContentFolderPeer
$criterion = $criteria->getNewCriterion(ContentFolderPeer::CONTENT_ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(ContentFolderPeer::FOLDER_ID, $value[1]));
$criteria->addOr($criterion);
+ // we can invalidate the cache for this single PK
+ ContentFolderPeer::removeInstanceFromPool($value);
}
}
@@ -672,23 +1304,6 @@ abstract class BaseContentFolderPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ContentFolderPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ContentFolderPeer::clearInstancePool();
- } elseif ($values instanceof ContentFolder) { // it's a model object
- ContentFolderPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ContentFolderPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ContentFolderPeer::clearRelatedInstancePool();
$con->commit();
@@ -700,45 +1315,6 @@ abstract class BaseContentFolderPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ContentFolderPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Content objects
- $criteria = new Criteria(ContentPeer::DATABASE_NAME);
-
- $criteria->add(ContentPeer::ID, $obj->getContentId());
- $affectedRows += ContentPeer::doDelete($criteria, $con);
-
- // delete related Folder objects
- $criteria = new Criteria(FolderPeer::DATABASE_NAME);
-
- $criteria->add(FolderPeer::ID, $obj->getFolderId());
- $affectedRows += FolderPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ContentFolder object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php
index 9cca09084..ad5dffc3a 100644
--- a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php
+++ b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php
@@ -61,7 +61,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ContentFolder', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ContentFolder', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -250,6 +250,8 @@ abstract class BaseContentFolderQuery extends ModelCriteria
* $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
*
*
+ * @see filterByContent()
+ *
* @param mixed $contentId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -277,6 +279,8 @@ abstract class BaseContentFolderQuery extends ModelCriteria
* $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
*
*
+ * @see filterByFolder()
+ *
* @param mixed $folderId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -297,7 +301,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria
/**
* Filter the query by a related Content object
*
- * @param Content|PropelObjectCollection $content the related object to use as filter
+ * @param Content|PropelObjectCollection $content The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ContentFolderQuery The current query, for fluid interface
@@ -309,10 +313,12 @@ abstract class BaseContentFolderQuery extends ModelCriteria
return $this
->addUsingAlias(ContentFolderPeer::CONTENT_ID, $content->getId(), $comparison);
} elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useContentQuery()
- ->filterByPrimaryKeys($content->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ContentFolderPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
}
@@ -371,7 +377,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria
/**
* Filter the query by a related Folder object
*
- * @param Folder|PropelObjectCollection $folder the related object to use as filter
+ * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ContentFolderQuery The current query, for fluid interface
@@ -383,10 +389,12 @@ abstract class BaseContentFolderQuery extends ModelCriteria
return $this
->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folder->getId(), $comparison);
} elseif ($folder instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useFolderQuery()
- ->filterByPrimaryKeys($folder->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseContentPeer.php b/core/lib/Thelia/Model/om/BaseContentPeer.php
index d992319df..85f317aa4 100644
--- a/core/lib/Thelia/Model/om/BaseContentPeer.php
+++ b/core/lib/Thelia/Model/om/BaseContentPeer.php
@@ -30,7 +30,7 @@ abstract class BaseContentPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'content';
@@ -388,6 +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,
+ // 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 ImagePeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ImagePeer::clearInstancePool();
+ // Invalidate objects in RewritingPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ RewritingPeer::clearInstancePool();
}
/**
@@ -484,2339 +502,6 @@ abstract class BaseContentPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentAssoc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinContentAssoc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinContentDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentFolder table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinContentFolder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Document table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinDocument(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Image table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinImage(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Rewriting table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinRewriting(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with their ContentAssoc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinContentAssoc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol = ContentPeer::NUM_HYDRATE_COLUMNS;
- ContentAssocPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Content) to $obj2 (ContentAssoc)
- // one to one relationship
- $obj1->setContentAssoc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with their ContentDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinContentDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol = ContentPeer::NUM_HYDRATE_COLUMNS;
- ContentDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ContentDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ContentDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ContentDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Content) to $obj2 (ContentDesc)
- // one to one relationship
- $obj1->setContentDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with their ContentFolder objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinContentFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol = ContentPeer::NUM_HYDRATE_COLUMNS;
- ContentFolderPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ContentFolderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ContentFolderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Content) to $obj2 (ContentFolder)
- // one to one relationship
- $obj1->setContentFolder($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with their Document objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol = ContentPeer::NUM_HYDRATE_COLUMNS;
- DocumentPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = DocumentPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- DocumentPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Content) to $obj2 (Document)
- // one to one relationship
- $obj1->setDocument($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with their Image objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol = ContentPeer::NUM_HYDRATE_COLUMNS;
- ImagePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ImagePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ImagePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Content) to $obj2 (Image)
- // one to one relationship
- $obj1->setImage($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with their Rewriting objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinRewriting(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol = ContentPeer::NUM_HYDRATE_COLUMNS;
- RewritingPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = RewritingPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- RewritingPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Content) to $obj2 (Rewriting)
- // one to one relationship
- $obj1->setRewriting($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Content objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol2 = ContentPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- ContentDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentAssoc rows
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Content) to the collection in $obj2 (ContentAssoc)
- $obj1->setContentAssoc($obj2);
- } // if joined row not null
-
- // Add objects for joined ContentDesc rows
-
- $key3 = ContentDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentDescPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Content) to the collection in $obj3 (ContentDesc)
- $obj1->setContentDesc($obj3);
- } // if joined row not null
-
- // Add objects for joined ContentFolder rows
-
- $key4 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentFolderPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentFolderPeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (Content) to the collection in $obj4 (ContentFolder)
- $obj1->setContentFolder($obj4);
- } // if joined row not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if obj5 loaded
-
- // Add the $obj1 (Content) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
- } // if joined row not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if obj6 loaded
-
- // Add the $obj1 (Content) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
- } // if joined row not null
-
- // Add objects for joined Rewriting rows
-
- $key7 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = RewritingPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- RewritingPeer::addInstanceToPool($obj7, $key7);
- } // if obj7 loaded
-
- // Add the $obj1 (Content) to the collection in $obj7 (Rewriting)
- $obj1->setRewriting($obj7);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentAssoc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptContentAssoc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptContentDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentFolder table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptContentFolder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Document table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptDocument(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Image table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptImage(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Rewriting table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptRewriting(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ContentPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with all related objects except ContentAssoc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptContentAssoc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol2 = ContentPeer::NUM_HYDRATE_COLUMNS;
-
- ContentDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentDesc rows
-
- $key2 = ContentDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj2 (ContentDesc)
- $obj1->setContentDesc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined ContentFolder rows
-
- $key3 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentFolderPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentFolderPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj3 (ContentFolder)
- $obj1->setContentFolder($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key4 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = DocumentPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- DocumentPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj4 (Document)
- $obj1->setDocument($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key5 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = ImagePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- ImagePeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj5 (Image)
- $obj1->setImage($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key6 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = RewritingPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- RewritingPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj6 (Rewriting)
- $obj1->setRewriting($obj6);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with all related objects except ContentDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptContentDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol2 = ContentPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentAssoc rows
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj2 (ContentAssoc)
- $obj1->setContentAssoc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined ContentFolder rows
-
- $key3 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentFolderPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentFolderPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj3 (ContentFolder)
- $obj1->setContentFolder($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key4 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = DocumentPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- DocumentPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj4 (Document)
- $obj1->setDocument($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key5 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = ImagePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- ImagePeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj5 (Image)
- $obj1->setImage($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key6 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = RewritingPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- RewritingPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj6 (Rewriting)
- $obj1->setRewriting($obj6);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with all related objects except ContentFolder.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptContentFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol2 = ContentPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- ContentDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentDescPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentAssoc rows
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj2 (ContentAssoc)
- $obj1->setContentAssoc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined ContentDesc rows
-
- $key3 = ContentDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj3 (ContentDesc)
- $obj1->setContentDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key4 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = DocumentPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- DocumentPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj4 (Document)
- $obj1->setDocument($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key5 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = ImagePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- ImagePeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj5 (Image)
- $obj1->setImage($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key6 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = RewritingPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- RewritingPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj6 (Rewriting)
- $obj1->setRewriting($obj6);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with all related objects except Document.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol2 = ContentPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- ContentDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentAssoc rows
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj2 (ContentAssoc)
- $obj1->setContentAssoc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined ContentDesc rows
-
- $key3 = ContentDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj3 (ContentDesc)
- $obj1->setContentDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentFolder rows
-
- $key4 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentFolderPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentFolderPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj4 (ContentFolder)
- $obj1->setContentFolder($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key5 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = ImagePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- ImagePeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj5 (Image)
- $obj1->setImage($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key6 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = RewritingPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- RewritingPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj6 (Rewriting)
- $obj1->setRewriting($obj6);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with all related objects except Image.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol2 = ContentPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- ContentDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, RewritingPeer::CONTENT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentAssoc rows
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj2 (ContentAssoc)
- $obj1->setContentAssoc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined ContentDesc rows
-
- $key3 = ContentDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj3 (ContentDesc)
- $obj1->setContentDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentFolder rows
-
- $key4 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentFolderPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentFolderPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj4 (ContentFolder)
- $obj1->setContentFolder($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key6 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = RewritingPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- RewritingPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj6 (Rewriting)
- $obj1->setRewriting($obj6);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Content objects pre-filled with all related objects except Rewriting.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Content objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptRewriting(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ContentPeer::DATABASE_NAME);
- }
-
- ContentPeer::addSelectColumns($criteria);
- $startcol2 = ContentPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- ContentDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ContentDescPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ContentPeer::ID, ContentAssocPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentDescPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ContentFolderPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, DocumentPeer::CONTENT_ID, $join_behavior);
-
- $criteria->addJoin(ContentPeer::ID, ImagePeer::CONTENT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ContentPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ContentPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ContentPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentAssoc rows
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj2 (ContentAssoc)
- $obj1->setContentAssoc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined ContentDesc rows
-
- $key3 = ContentDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ContentDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ContentDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ContentDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj3 (ContentDesc)
- $obj1->setContentDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentFolder rows
-
- $key4 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentFolderPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentFolderPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj4 (ContentFolder)
- $obj1->setContentFolder($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Content) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseContentQuery.php b/core/lib/Thelia/Model/om/BaseContentQuery.php
index 313aef22f..6c0e852ed 100644
--- a/core/lib/Thelia/Model/om/BaseContentQuery.php
+++ b/core/lib/Thelia/Model/om/BaseContentQuery.php
@@ -93,7 +93,7 @@ abstract class BaseContentQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Content', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Content', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -269,18 +269,6 @@ abstract class BaseContentQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByContentAssoc()
- *
- * @see filterByContentDesc()
- *
- * @see filterByContentFolder()
- *
- * @see filterByDocument()
- *
- * @see filterByImage()
- *
- * @see filterByRewriting()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -469,7 +457,7 @@ abstract class BaseContentQuery extends ModelCriteria
/**
* Filter the query by a related ContentAssoc object
*
- * @param ContentAssoc|PropelObjectCollection $contentAssoc The related object(s) 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
@@ -481,12 +469,10 @@ abstract class BaseContentQuery extends ModelCriteria
return $this
->addUsingAlias(ContentPeer::ID, $contentAssoc->getContentId(), $comparison);
} elseif ($contentAssoc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ContentPeer::ID, $contentAssoc->toKeyValue('PrimaryKey', 'ContentId'), $comparison);
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection');
}
@@ -500,7 +486,7 @@ abstract class BaseContentQuery extends ModelCriteria
*
* @return ContentQuery The current query, for fluid interface
*/
- public function joinContentAssoc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('ContentAssoc');
@@ -535,7 +521,7 @@ abstract class BaseContentQuery extends ModelCriteria
*
* @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
*/
- public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinContentAssoc($relationAlias, $joinType)
@@ -545,7 +531,7 @@ abstract class BaseContentQuery extends ModelCriteria
/**
* Filter the query by a related ContentDesc object
*
- * @param ContentDesc|PropelObjectCollection $contentDesc The related object(s) to use as filter
+ * @param ContentDesc|PropelObjectCollection $contentDesc 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
@@ -557,12 +543,10 @@ abstract class BaseContentQuery extends ModelCriteria
return $this
->addUsingAlias(ContentPeer::ID, $contentDesc->getContentId(), $comparison);
} elseif ($contentDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ContentPeer::ID, $contentDesc->toKeyValue('PrimaryKey', 'ContentId'), $comparison);
+ ->useContentDescQuery()
+ ->filterByPrimaryKeys($contentDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByContentDesc() only accepts arguments of type ContentDesc or PropelCollection');
}
@@ -621,7 +605,7 @@ abstract class BaseContentQuery extends ModelCriteria
/**
* Filter the query by a related ContentFolder object
*
- * @param ContentFolder|PropelObjectCollection $contentFolder The related object(s) to use as filter
+ * @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
@@ -633,12 +617,10 @@ abstract class BaseContentQuery extends ModelCriteria
return $this
->addUsingAlias(ContentPeer::ID, $contentFolder->getContentId(), $comparison);
} elseif ($contentFolder instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ContentPeer::ID, $contentFolder->toKeyValue('ContentId', 'ContentId'), $comparison);
+ ->useContentFolderQuery()
+ ->filterByPrimaryKeys($contentFolder->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection');
}
@@ -697,7 +679,7 @@ abstract class BaseContentQuery extends ModelCriteria
/**
* Filter the query by a related Document object
*
- * @param Document|PropelObjectCollection $document The related object(s) 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 ContentQuery The current query, for fluid interface
@@ -709,12 +691,10 @@ abstract class BaseContentQuery extends ModelCriteria
return $this
->addUsingAlias(ContentPeer::ID, $document->getContentId(), $comparison);
} elseif ($document instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ContentPeer::ID, $document->toKeyValue('PrimaryKey', 'ContentId'), $comparison);
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
}
@@ -728,7 +708,7 @@ abstract class BaseContentQuery extends ModelCriteria
*
* @return ContentQuery The current query, for fluid interface
*/
- public function joinDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Document');
@@ -763,7 +743,7 @@ abstract class BaseContentQuery extends ModelCriteria
*
* @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
*/
- public function useDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinDocument($relationAlias, $joinType)
@@ -773,7 +753,7 @@ abstract class BaseContentQuery extends ModelCriteria
/**
* Filter the query by a related Image object
*
- * @param Image|PropelObjectCollection $image The related object(s) to use as filter
+ * @param Image|PropelObjectCollection $image the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ContentQuery The current query, for fluid interface
@@ -785,12 +765,10 @@ abstract class BaseContentQuery extends ModelCriteria
return $this
->addUsingAlias(ContentPeer::ID, $image->getContentId(), $comparison);
} elseif ($image instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ContentPeer::ID, $image->toKeyValue('PrimaryKey', 'ContentId'), $comparison);
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
}
@@ -804,7 +782,7 @@ abstract class BaseContentQuery extends ModelCriteria
*
* @return ContentQuery The current query, for fluid interface
*/
- public function joinImage($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Image');
@@ -839,7 +817,7 @@ abstract class BaseContentQuery extends ModelCriteria
*
* @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
*/
- public function useImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinImage($relationAlias, $joinType)
@@ -849,7 +827,7 @@ abstract class BaseContentQuery extends ModelCriteria
/**
* Filter the query by a related Rewriting object
*
- * @param Rewriting|PropelObjectCollection $rewriting The related object(s) to use as filter
+ * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ContentQuery The current query, for fluid interface
@@ -861,12 +839,10 @@ abstract class BaseContentQuery extends ModelCriteria
return $this
->addUsingAlias(ContentPeer::ID, $rewriting->getContentId(), $comparison);
} elseif ($rewriting instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ContentPeer::ID, $rewriting->toKeyValue('PrimaryKey', 'ContentId'), $comparison);
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection');
}
@@ -880,7 +856,7 @@ abstract class BaseContentQuery extends ModelCriteria
*
* @return ContentQuery The current query, for fluid interface
*/
- public function joinRewriting($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Rewriting');
@@ -915,7 +891,7 @@ abstract class BaseContentQuery extends ModelCriteria
*
* @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query
*/
- public function useRewritingQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinRewriting($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseCountry.php b/core/lib/Thelia/Model/om/BaseCountry.php
index 960519bd1..b19a6f777 100644
--- a/core/lib/Thelia/Model/om/BaseCountry.php
+++ b/core/lib/Thelia/Model/om/BaseCountry.php
@@ -96,19 +96,21 @@ abstract class BaseCountry extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var CountryDesc
+ * @var Area
*/
- protected $aCountryDesc;
+ protected $aArea;
/**
- * @var TaxRuleCountry
+ * @var PropelObjectCollection|CountryDesc[] Collection to store aggregation of CountryDesc objects.
*/
- protected $aTaxRuleCountry;
+ protected $collCountryDescs;
+ protected $collCountryDescsPartial;
/**
- * @var Area one-to-one related Area object
+ * @var PropelObjectCollection|TaxRuleCountry[] Collection to store aggregation of TaxRuleCountry objects.
*/
- protected $singleArea;
+ protected $collTaxRuleCountrys;
+ protected $collTaxRuleCountrysPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -128,7 +130,13 @@ abstract class BaseCountry extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $areasScheduledForDeletion = null;
+ protected $countryDescsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $taxRuleCountrysScheduledForDeletion = null;
/**
* Get the [id] column value.
@@ -271,14 +279,6 @@ abstract class BaseCountry extends BaseObject implements Persistent
$this->modifiedColumns[] = CountryPeer::ID;
}
- if ($this->aCountryDesc !== null && $this->aCountryDesc->getCountryId() !== $v) {
- $this->aCountryDesc = null;
- }
-
- if ($this->aTaxRuleCountry !== null && $this->aTaxRuleCountry->getCountryId() !== $v) {
- $this->aTaxRuleCountry = null;
- }
-
return $this;
} // setId()
@@ -300,6 +300,10 @@ abstract class BaseCountry extends BaseObject implements Persistent
$this->modifiedColumns[] = CountryPeer::AREA_ID;
}
+ if ($this->aArea !== null && $this->aArea->getId() !== $v) {
+ $this->aArea = null;
+ }
+
return $this;
} // setAreaId()
@@ -483,11 +487,8 @@ abstract class BaseCountry extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aCountryDesc !== null && $this->id !== $this->aCountryDesc->getCountryId()) {
- $this->aCountryDesc = null;
- }
- if ($this->aTaxRuleCountry !== null && $this->id !== $this->aTaxRuleCountry->getCountryId()) {
- $this->aTaxRuleCountry = null;
+ if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) {
+ $this->aArea = null;
}
} // ensureConsistency
@@ -528,9 +529,10 @@ abstract class BaseCountry extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aCountryDesc = null;
- $this->aTaxRuleCountry = null;
- $this->singleArea = null;
+ $this->aArea = null;
+ $this->collCountryDescs = null;
+
+ $this->collTaxRuleCountrys = null;
} // if (deep)
}
@@ -650,18 +652,11 @@ abstract class BaseCountry extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aCountryDesc !== null) {
- if ($this->aCountryDesc->isModified() || $this->aCountryDesc->isNew()) {
- $affectedRows += $this->aCountryDesc->save($con);
+ if ($this->aArea !== null) {
+ if ($this->aArea->isModified() || $this->aArea->isNew()) {
+ $affectedRows += $this->aArea->save($con);
}
- $this->setCountryDesc($this->aCountryDesc);
- }
-
- if ($this->aTaxRuleCountry !== null) {
- if ($this->aTaxRuleCountry->isModified() || $this->aTaxRuleCountry->isNew()) {
- $affectedRows += $this->aTaxRuleCountry->save($con);
- }
- $this->setTaxRuleCountry($this->aTaxRuleCountry);
+ $this->setArea($this->aArea);
}
if ($this->isNew() || $this->isModified()) {
@@ -675,18 +670,38 @@ abstract class BaseCountry extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->areasScheduledForDeletion !== null) {
- if (!$this->areasScheduledForDeletion->isEmpty()) {
- AreaQuery::create()
- ->filterByPrimaryKeys($this->areasScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->countryDescsScheduledForDeletion !== null) {
+ if (!$this->countryDescsScheduledForDeletion->isEmpty()) {
+ CountryDescQuery::create()
+ ->filterByPrimaryKeys($this->countryDescsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->areasScheduledForDeletion = null;
+ $this->countryDescsScheduledForDeletion = null;
}
}
- if ($this->singleArea !== null) {
- if (!$this->singleArea->isDeleted()) {
- $affectedRows += $this->singleArea->save($con);
+ if ($this->collCountryDescs !== null) {
+ foreach ($this->collCountryDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ 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);
+ }
}
}
@@ -857,15 +872,9 @@ abstract class BaseCountry extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aCountryDesc !== null) {
- if (!$this->aCountryDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aCountryDesc->getValidationFailures());
- }
- }
-
- if ($this->aTaxRuleCountry !== null) {
- if (!$this->aTaxRuleCountry->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aTaxRuleCountry->getValidationFailures());
+ if ($this->aArea !== null) {
+ if (!$this->aArea->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aArea->getValidationFailures());
}
}
@@ -875,9 +884,19 @@ abstract class BaseCountry extends BaseObject implements Persistent
}
- if ($this->singleArea !== null) {
- if (!$this->singleArea->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleArea->getValidationFailures());
+ if ($this->collCountryDescs !== null) {
+ foreach ($this->collCountryDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collTaxRuleCountrys !== null) {
+ foreach ($this->collTaxRuleCountrys as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
}
}
@@ -975,14 +994,14 @@ abstract class BaseCountry extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aCountryDesc) {
- $result['CountryDesc'] = $this->aCountryDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aArea) {
+ $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->aTaxRuleCountry) {
- $result['TaxRuleCountry'] = $this->aTaxRuleCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collCountryDescs) {
+ $result['CountryDescs'] = $this->collCountryDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->singleArea) {
- $result['Area'] = $this->singleArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collTaxRuleCountrys) {
+ $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1165,19 +1184,16 @@ abstract class BaseCountry extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getArea();
- if ($relObj) {
- $copyObj->setArea($relObj->copy($deepCopy));
+ foreach ($this->getCountryDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCountryDesc($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getCountryDesc();
- if ($relObj) {
- $copyObj->setCountryDesc($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getTaxRuleCountry();
- if ($relObj) {
- $copyObj->setTaxRuleCountry($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
@@ -1231,25 +1247,26 @@ abstract class BaseCountry extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a CountryDesc object.
+ * Declares an association between this object and a Area object.
*
- * @param CountryDesc $v
+ * @param Area $v
* @return Country The current object (for fluent API support)
* @throws PropelException
*/
- public function setCountryDesc(CountryDesc $v = null)
+ public function setArea(Area $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setAreaId(NULL);
} else {
- $this->setId($v->getCountryId());
+ $this->setAreaId($v->getId());
}
- $this->aCountryDesc = $v;
+ $this->aArea = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Area object, it will not be re-added.
if ($v !== null) {
- $v->setCountry($this);
+ $v->addCountry($this);
}
@@ -1258,70 +1275,26 @@ abstract class BaseCountry extends BaseObject implements Persistent
/**
- * Get the associated CountryDesc object
+ * Get the associated Area object
*
* @param PropelPDO $con Optional Connection object.
- * @return CountryDesc The associated CountryDesc object.
+ * @return Area The associated Area object.
* @throws PropelException
*/
- public function getCountryDesc(PropelPDO $con = null)
+ public function getArea(PropelPDO $con = null)
{
- if ($this->aCountryDesc === null && ($this->id !== null)) {
- $this->aCountryDesc = CountryDescQuery::create()
- ->filterByCountry($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aCountryDesc->setCountry($this);
+ if ($this->aArea === null && ($this->area_id !== null)) {
+ $this->aArea = AreaQuery::create()->findPk($this->area_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->aArea->addCountrys($this);
+ */
}
- return $this->aCountryDesc;
- }
-
- /**
- * Declares an association between this object and a TaxRuleCountry object.
- *
- * @param TaxRuleCountry $v
- * @return Country The current object (for fluent API support)
- * @throws PropelException
- */
- public function setTaxRuleCountry(TaxRuleCountry $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getCountryId());
- }
-
- $this->aTaxRuleCountry = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCountry($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated TaxRuleCountry object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return TaxRuleCountry The associated TaxRuleCountry object.
- * @throws PropelException
- */
- public function getTaxRuleCountry(PropelPDO $con = null)
- {
- if ($this->aTaxRuleCountry === null && ($this->id !== null)) {
- $this->aTaxRuleCountry = TaxRuleCountryQuery::create()
- ->filterByCountry($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aTaxRuleCountry->setCountry($this);
- }
-
- return $this->aTaxRuleCountry;
+ return $this->aArea;
}
@@ -1335,44 +1308,478 @@ abstract class BaseCountry extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ if ('CountryDesc' == $relationName) {
+ $this->initCountryDescs();
+ }
+ if ('TaxRuleCountry' == $relationName) {
+ $this->initTaxRuleCountrys();
+ }
}
/**
- * Gets a single Area object, which is related to this object by a one-to-one relationship.
+ * Clears out the collCountryDescs 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 addCountryDescs()
+ */
+ public function clearCountryDescs()
+ {
+ $this->collCountryDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collCountryDescsPartial = null;
+ }
+
+ /**
+ * reset is the collCountryDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialCountryDescs($v = true)
+ {
+ $this->collCountryDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCountryDescs collection.
+ *
+ * By default this just sets the collCountryDescs collection to an empty array (like clearcollCountryDescs());
+ * 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 initCountryDescs($overrideExisting = true)
+ {
+ if (null !== $this->collCountryDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collCountryDescs = new PropelObjectCollection();
+ $this->collCountryDescs->setModel('CountryDesc');
+ }
+
+ /**
+ * Gets an array of CountryDesc 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 Country 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 Area
+ * @return PropelObjectCollection|CountryDesc[] List of CountryDesc objects
* @throws PropelException
*/
- public function getArea(PropelPDO $con = null)
+ public function getCountryDescs($criteria = null, PropelPDO $con = null)
{
+ $partial = $this->collCountryDescsPartial && !$this->isNew();
+ if (null === $this->collCountryDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCountryDescs) {
+ // return empty collection
+ $this->initCountryDescs();
+ } else {
+ $collCountryDescs = CountryDescQuery::create(null, $criteria)
+ ->filterByCountry($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCountryDescsPartial && count($collCountryDescs)) {
+ $this->initCountryDescs(false);
- if ($this->singleArea === null && !$this->isNew()) {
- $this->singleArea = AreaQuery::create()->findPk($this->getPrimaryKey(), $con);
+ foreach($collCountryDescs as $obj) {
+ if (false == $this->collCountryDescs->contains($obj)) {
+ $this->collCountryDescs->append($obj);
+ }
+ }
+
+ $this->collCountryDescsPartial = true;
+ }
+
+ return $collCountryDescs;
+ }
+
+ if($partial && $this->collCountryDescs) {
+ foreach($this->collCountryDescs as $obj) {
+ if($obj->isNew()) {
+ $collCountryDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collCountryDescs = $collCountryDescs;
+ $this->collCountryDescsPartial = false;
+ }
}
- return $this->singleArea;
+ return $this->collCountryDescs;
}
/**
- * Sets a single Area object as related to this object by a one-to-one relationship.
+ * Sets a collection of CountryDesc 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 Area $v Area
- * @return Country The current object (for fluent API support)
+ * @param PropelCollection $countryDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setCountryDescs(PropelCollection $countryDescs, PropelPDO $con = null)
+ {
+ $this->countryDescsScheduledForDeletion = $this->getCountryDescs(new Criteria(), $con)->diff($countryDescs);
+
+ foreach ($this->countryDescsScheduledForDeletion as $countryDescRemoved) {
+ $countryDescRemoved->setCountry(null);
+ }
+
+ $this->collCountryDescs = null;
+ foreach ($countryDescs as $countryDesc) {
+ $this->addCountryDesc($countryDesc);
+ }
+
+ $this->collCountryDescs = $countryDescs;
+ $this->collCountryDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related CountryDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CountryDesc objects.
* @throws PropelException
*/
- public function setArea(Area $v = null)
+ public function countCountryDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleArea = $v;
+ $partial = $this->collCountryDescsPartial && !$this->isNew();
+ if (null === $this->collCountryDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCountryDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getCountryDescs());
+ }
+ $query = CountryDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
- // Make sure that that the passed-in Area isn't already associated with this object
- if ($v !== null && $v->getCountry() === null) {
- $v->setCountry($this);
+ return $query
+ ->filterByCountry($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCountryDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a CountryDesc object to this object
+ * through the CountryDesc foreign key attribute.
+ *
+ * @param CountryDesc $l CountryDesc
+ * @return Country The current object (for fluent API support)
+ */
+ public function addCountryDesc(CountryDesc $l)
+ {
+ if ($this->collCountryDescs === null) {
+ $this->initCountryDescs();
+ $this->collCountryDescsPartial = true;
+ }
+ if (!$this->collCountryDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddCountryDesc($l);
}
return $this;
}
+ /**
+ * @param CountryDesc $countryDesc The countryDesc object to add.
+ */
+ protected function doAddCountryDesc($countryDesc)
+ {
+ $this->collCountryDescs[]= $countryDesc;
+ $countryDesc->setCountry($this);
+ }
+
+ /**
+ * @param CountryDesc $countryDesc The countryDesc object to remove.
+ */
+ public function removeCountryDesc($countryDesc)
+ {
+ if ($this->getCountryDescs()->contains($countryDesc)) {
+ $this->collCountryDescs->remove($this->collCountryDescs->search($countryDesc));
+ if (null === $this->countryDescsScheduledForDeletion) {
+ $this->countryDescsScheduledForDeletion = clone $this->collCountryDescs;
+ $this->countryDescsScheduledForDeletion->clear();
+ }
+ $this->countryDescsScheduledForDeletion[]= $countryDesc;
+ $countryDesc->setCountry(null);
+ }
+ }
+
+ /**
+ * Clears out the collTaxRuleCountrys 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 addTaxRuleCountrys()
+ */
+ public function clearTaxRuleCountrys()
+ {
+ $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized
+ $this->collTaxRuleCountrysPartial = null;
+ }
+
+ /**
+ * reset is the collTaxRuleCountrys collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialTaxRuleCountrys($v = true)
+ {
+ $this->collTaxRuleCountrysPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxRuleCountrys collection.
+ *
+ * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys());
+ * 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 initTaxRuleCountrys($overrideExisting = true)
+ {
+ if (null !== $this->collTaxRuleCountrys && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxRuleCountrys = new PropelObjectCollection();
+ $this->collTaxRuleCountrys->setModel('TaxRuleCountry');
+ }
+
+ /**
+ * Gets an array of TaxRuleCountry 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 Country 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|TaxRuleCountry[] List of TaxRuleCountry objects
+ * @throws PropelException
+ */
+ public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collTaxRuleCountrysPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountrys) {
+ // return empty collection
+ $this->initTaxRuleCountrys();
+ } else {
+ $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria)
+ ->filterByCountry($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) {
+ $this->initTaxRuleCountrys(false);
+
+ foreach($collTaxRuleCountrys as $obj) {
+ if (false == $this->collTaxRuleCountrys->contains($obj)) {
+ $this->collTaxRuleCountrys->append($obj);
+ }
+ }
+
+ $this->collTaxRuleCountrysPartial = true;
+ }
+
+ return $collTaxRuleCountrys;
+ }
+
+ if($partial && $this->collTaxRuleCountrys) {
+ foreach($this->collTaxRuleCountrys as $obj) {
+ if($obj->isNew()) {
+ $collTaxRuleCountrys[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxRuleCountrys = $collTaxRuleCountrys;
+ $this->collTaxRuleCountrysPartial = false;
+ }
+ }
+
+ return $this->collTaxRuleCountrys;
+ }
+
+ /**
+ * Sets a collection of TaxRuleCountry 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 $taxRuleCountrys A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null)
+ {
+ $this->taxRuleCountrysScheduledForDeletion = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys);
+
+ foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountryRemoved) {
+ $taxRuleCountryRemoved->setCountry(null);
+ }
+
+ $this->collTaxRuleCountrys = null;
+ foreach ($taxRuleCountrys as $taxRuleCountry) {
+ $this->addTaxRuleCountry($taxRuleCountry);
+ }
+
+ $this->collTaxRuleCountrys = $taxRuleCountrys;
+ $this->collTaxRuleCountrysPartial = false;
+ }
+
+ /**
+ * Returns the number of related TaxRuleCountry objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related TaxRuleCountry objects.
+ * @throws PropelException
+ */
+ public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collTaxRuleCountrysPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountrys) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getTaxRuleCountrys());
+ }
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCountry($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collTaxRuleCountrys);
+ }
+ }
+
+ /**
+ * Method called to associate a TaxRuleCountry object to this object
+ * through the TaxRuleCountry foreign key attribute.
+ *
+ * @param TaxRuleCountry $l TaxRuleCountry
+ * @return Country The current object (for fluent API support)
+ */
+ public function addTaxRuleCountry(TaxRuleCountry $l)
+ {
+ if ($this->collTaxRuleCountrys === null) {
+ $this->initTaxRuleCountrys();
+ $this->collTaxRuleCountrysPartial = true;
+ }
+ if (!$this->collTaxRuleCountrys->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxRuleCountry($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add.
+ */
+ protected function doAddTaxRuleCountry($taxRuleCountry)
+ {
+ $this->collTaxRuleCountrys[]= $taxRuleCountry;
+ $taxRuleCountry->setCountry($this);
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove.
+ */
+ public function removeTaxRuleCountry($taxRuleCountry)
+ {
+ if ($this->getTaxRuleCountrys()->contains($taxRuleCountry)) {
+ $this->collTaxRuleCountrys->remove($this->collTaxRuleCountrys->search($taxRuleCountry));
+ if (null === $this->taxRuleCountrysScheduledForDeletion) {
+ $this->taxRuleCountrysScheduledForDeletion = clone $this->collTaxRuleCountrys;
+ $this->taxRuleCountrysScheduledForDeletion->clear();
+ }
+ $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry;
+ $taxRuleCountry->setCountry(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Country is new, it will return
+ * an empty collection; or if this Country has previously
+ * been saved, it will retrieve related TaxRuleCountrys 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 Country.
+ *
+ * @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|TaxRuleCountry[] List of TaxRuleCountry objects
+ */
+ public function getTaxRuleCountrysJoinTax($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('Tax', $join_behavior);
+
+ return $this->getTaxRuleCountrys($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Country is new, it will return
+ * an empty collection; or if this Country has previously
+ * been saved, it will retrieve related TaxRuleCountrys 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 Country.
+ *
+ * @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|TaxRuleCountry[] List of TaxRuleCountry objects
+ */
+ public function getTaxRuleCountrysJoinTaxRule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('TaxRule', $join_behavior);
+
+ return $this->getTaxRuleCountrys($query, $con);
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1405,17 +1812,27 @@ abstract class BaseCountry extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleArea) {
- $this->singleArea->clearAllReferences($deep);
+ if ($this->collCountryDescs) {
+ foreach ($this->collCountryDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collTaxRuleCountrys) {
+ foreach ($this->collTaxRuleCountrys as $o) {
+ $o->clearAllReferences($deep);
+ }
}
} // if ($deep)
- if ($this->singleArea instanceof PropelCollection) {
- $this->singleArea->clearIterator();
+ if ($this->collCountryDescs instanceof PropelCollection) {
+ $this->collCountryDescs->clearIterator();
}
- $this->singleArea = null;
- $this->aCountryDesc = null;
- $this->aTaxRuleCountry = null;
+ $this->collCountryDescs = null;
+ if ($this->collTaxRuleCountrys instanceof PropelCollection) {
+ $this->collTaxRuleCountrys->clearIterator();
+ }
+ $this->collTaxRuleCountrys = null;
+ $this->aArea = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCountryDesc.php b/core/lib/Thelia/Model/om/BaseCountryDesc.php
index 4c229591d..105007c9b 100644
--- a/core/lib/Thelia/Model/om/BaseCountryDesc.php
+++ b/core/lib/Thelia/Model/om/BaseCountryDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Country;
use Thelia\Model\CountryDesc;
@@ -98,9 +96,9 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Country one-to-one related Country object
+ * @var Country
*/
- protected $singleCountry;
+ protected $aCountry;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $countrysScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -294,6 +286,10 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = CountryDescPeer::COUNTRY_ID;
}
+ if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
+ $this->aCountry = null;
+ }
+
return $this;
} // setCountryId()
@@ -499,6 +495,9 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
+ $this->aCountry = null;
+ }
} // ensureConsistency
/**
@@ -538,8 +537,7 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCountry = null;
-
+ $this->aCountry = null;
} // if (deep)
}
@@ -653,6 +651,18 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCountry !== null) {
+ if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
+ $affectedRows += $this->aCountry->save($con);
+ }
+ $this->setCountry($this->aCountry);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -664,21 +674,6 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->countrysScheduledForDeletion !== null) {
- if (!$this->countrysScheduledForDeletion->isEmpty()) {
- CountryQuery::create()
- ->filterByPrimaryKeys($this->countrysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->countrysScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCountry !== null) {
- if (!$this->singleCountry->isDeleted()) {
- $affectedRows += $this->singleCountry->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -858,17 +853,23 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCountry !== null) {
+ if (!$this->aCountry->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCountry->getValidationFailures());
+ }
+ }
+
+
if (($retval = CountryDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCountry !== null) {
- if (!$this->singleCountry->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCountry->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -967,8 +968,8 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCountry) {
- $result['Country'] = $this->singleCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCountry) {
+ $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1157,11 +1158,6 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCountry();
- if ($relObj) {
- $copyObj->setCountry($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1212,55 +1208,57 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Country object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Country object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Country
- * @throws PropelException
- */
- public function getCountry(PropelPDO $con = null)
- {
-
- if ($this->singleCountry === null && !$this->isNew()) {
- $this->singleCountry = CountryQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCountry;
- }
-
- /**
- * Sets a single Country object as related to this object by a one-to-one relationship.
- *
- * @param Country $v Country
+ * @param Country $v
* @return CountryDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setCountry(Country $v = null)
{
- $this->singleCountry = $v;
-
- // Make sure that that the passed-in Country isn't already associated with this object
- if ($v !== null && $v->getCountryDesc() === null) {
- $v->setCountryDesc($this);
+ if ($v === null) {
+ $this->setCountryId(NULL);
+ } else {
+ $this->setCountryId($v->getId());
}
+ $this->aCountry = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Country object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCountryDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Country object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Country The associated Country object.
+ * @throws PropelException
+ */
+ public function getCountry(PropelPDO $con = null)
+ {
+ if ($this->aCountry === null && ($this->country_id !== null)) {
+ $this->aCountry = CountryQuery::create()->findPk($this->country_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->aCountry->addCountryDescs($this);
+ */
+ }
+
+ return $this->aCountry;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1294,15 +1292,9 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCountry) {
- $this->singleCountry->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCountry instanceof PropelCollection) {
- $this->singleCountry->clearIterator();
- }
- $this->singleCountry = null;
+ $this->aCountry = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCountryDescPeer.php b/core/lib/Thelia/Model/om/BaseCountryDescPeer.php
index be5616efd..37394982f 100644
--- a/core/lib/Thelia/Model/om/BaseCountryDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCountryDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseCountryDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'country_desc';
@@ -398,9 +398,6 @@ abstract class BaseCountryDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CountryPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CountryPeer::clearInstancePool();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseCountryDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Country table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCountry(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CountryDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CountryDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CountryDescPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of CountryDesc objects pre-filled with their Country objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CountryDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME);
+ }
+
+ CountryDescPeer::addSelectColumns($criteria);
+ $startcol = CountryDescPeer::NUM_HYDRATE_COLUMNS;
+ CountryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CountryDescPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CountryDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CountryDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = CountryDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CountryDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CountryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CountryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CountryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (CountryDesc) to $obj2 (Country)
+ $obj2->addCountryDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CountryDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CountryDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CountryDescPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of CountryDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CountryDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME);
+ }
+
+ CountryDescPeer::addSelectColumns($criteria);
+ $startcol2 = CountryDescPeer::NUM_HYDRATE_COLUMNS;
+
+ CountryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CountryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CountryDescPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CountryDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CountryDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = CountryDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CountryDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Country rows
+
+ $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CountryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CountryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CountryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (CountryDesc) to the collection in $obj2 (Country)
+ $obj2->addCountryDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -630,7 +865,6 @@ abstract class BaseCountryDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += CountryDescPeer::doOnDeleteCascade(new Criteria(CountryDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CountryDescPeer::TABLE_NAME, $con, CountryDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +898,24 @@ abstract class BaseCountryDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CountryDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CountryDesc) { // it's a model object
+ // invalidate the cache for this single object
+ CountryDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CountryDescPeer::DATABASE_NAME);
$criteria->add(CountryDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CountryDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,23 +928,6 @@ abstract class BaseCountryDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += CountryDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- CountryDescPeer::clearInstancePool();
- } elseif ($values instanceof CountryDesc) { // it's a model object
- CountryDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- CountryDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
CountryDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -712,39 +939,6 @@ abstract class BaseCountryDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = CountryDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Country objects
- $criteria = new Criteria(CountryPeer::DATABASE_NAME);
-
- $criteria->add(CountryPeer::ID, $obj->getCountryId());
- $affectedRows += CountryPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given CountryDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseCountryDescQuery.php b/core/lib/Thelia/Model/om/BaseCountryDescQuery.php
index 780aa8451..3e71b9628 100644
--- a/core/lib/Thelia/Model/om/BaseCountryDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCountryDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseCountryDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\CountryDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\CountryDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -283,6 +283,8 @@ abstract class BaseCountryDescQuery extends ModelCriteria
* $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
*
*
+ * @see filterByCountry()
+ *
* @param mixed $countryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +521,7 @@ abstract class BaseCountryDescQuery extends ModelCriteria
/**
* Filter the query by a related Country object
*
- * @param Country|PropelObjectCollection $country the related object to use as filter
+ * @param Country|PropelObjectCollection $country The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CountryDescQuery The current query, for fluid interface
@@ -531,10 +533,12 @@ abstract class BaseCountryDescQuery extends ModelCriteria
return $this
->addUsingAlias(CountryDescPeer::COUNTRY_ID, $country->getId(), $comparison);
} elseif ($country instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCountryQuery()
- ->filterByPrimaryKeys($country->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(CountryDescPeer::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseCountryPeer.php b/core/lib/Thelia/Model/om/BaseCountryPeer.php
index 595406d34..9566871ba 100644
--- a/core/lib/Thelia/Model/om/BaseCountryPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCountryPeer.php
@@ -27,7 +27,7 @@ abstract class BaseCountryPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'country';
@@ -395,9 +395,12 @@ abstract class BaseCountryPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in AreaPeer instance pool,
+ // Invalidate objects in CountryDescPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- AreaPeer::clearInstancePool();
+ CountryDescPeer::clearInstancePool();
+ // Invalidate objects in TaxRuleCountryPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ TaxRuleCountryPeer::clearInstancePool();
}
/**
@@ -496,7 +499,7 @@ abstract class BaseCountryPeer
/**
- * Returns the number of rows matching criteria, joining the related CountryDesc table
+ * Returns the number of rows matching criteria, joining the related Area table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -504,7 +507,7 @@ abstract class BaseCountryPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinCountryDesc(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinArea(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;
@@ -531,7 +534,7 @@ abstract class BaseCountryPeer
$con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(CountryPeer::ID, CountryDescPeer::COUNTRY_ID, $join_behavior);
+ $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -547,58 +550,7 @@ abstract class BaseCountryPeer
/**
- * Returns the number of rows matching criteria, joining the related TaxRuleCountry table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinTaxRuleCountry(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CountryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CountryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CountryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CountryPeer::ID, TaxRuleCountryPeer::COUNTRY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Country objects pre-filled with their CountryDesc objects.
+ * Selects a collection of Country objects pre-filled with their Area objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -606,7 +558,7 @@ abstract class BaseCountryPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinCountryDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinArea(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -617,9 +569,9 @@ abstract class BaseCountryPeer
CountryPeer::addSelectColumns($criteria);
$startcol = CountryPeer::NUM_HYDRATE_COLUMNS;
- CountryDescPeer::addSelectColumns($criteria);
+ AreaPeer::addSelectColumns($criteria);
- $criteria->addJoin(CountryPeer::ID, CountryDescPeer::COUNTRY_ID, $join_behavior);
+ $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -639,89 +591,20 @@ abstract class BaseCountryPeer
CountryPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = CountryDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = CountryDescPeer::getInstanceFromPool($key2);
+ $obj2 = AreaPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = CountryDescPeer::getOMClass();
+ $cls = AreaPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- CountryDescPeer::addInstanceToPool($obj2, $key2);
+ AreaPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (Country) to $obj2 (CountryDesc)
- // one to one relationship
- $obj1->setCountryDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Country objects pre-filled with their TaxRuleCountry objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Country objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinTaxRuleCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CountryPeer::DATABASE_NAME);
- }
-
- CountryPeer::addSelectColumns($criteria);
- $startcol = CountryPeer::NUM_HYDRATE_COLUMNS;
- TaxRuleCountryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CountryPeer::ID, TaxRuleCountryPeer::COUNTRY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CountryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CountryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CountryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CountryPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = TaxRuleCountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- TaxRuleCountryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Country) to $obj2 (TaxRuleCountry)
- // one to one relationship
- $obj1->setTaxRuleCountry($obj2);
+ // Add the $obj1 (Country) to $obj2 (Area)
+ $obj2->addCountry($obj1);
} // if joined row was not null
@@ -769,9 +652,7 @@ abstract class BaseCountryPeer
$con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(CountryPeer::ID, CountryDescPeer::COUNTRY_ID, $join_behavior);
-
- $criteria->addJoin(CountryPeer::ID, TaxRuleCountryPeer::COUNTRY_ID, $join_behavior);
+ $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -807,15 +688,10 @@ abstract class BaseCountryPeer
CountryPeer::addSelectColumns($criteria);
$startcol2 = CountryPeer::NUM_HYDRATE_COLUMNS;
- CountryDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CountryDescPeer::NUM_HYDRATE_COLUMNS;
+ AreaPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AreaPeer::NUM_HYDRATE_COLUMNS;
- TaxRuleCountryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CountryPeer::ID, CountryDescPeer::COUNTRY_ID, $join_behavior);
-
- $criteria->addJoin(CountryPeer::ID, TaxRuleCountryPeer::COUNTRY_ID, $join_behavior);
+ $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -834,292 +710,24 @@ abstract class BaseCountryPeer
CountryPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined CountryDesc rows
+ // Add objects for joined Area rows
- $key2 = CountryDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = CountryDescPeer::getInstanceFromPool($key2);
+ $obj2 = AreaPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = CountryDescPeer::getOMClass();
+ $cls = AreaPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- CountryDescPeer::addInstanceToPool($obj2, $key2);
+ AreaPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (Country) to the collection in $obj2 (CountryDesc)
- $obj1->setCountryDesc($obj2);
+ // Add the $obj1 (Country) to the collection in $obj2 (Area)
+ $obj2->addCountry($obj1);
} // if joined row not null
- // Add objects for joined TaxRuleCountry rows
-
- $key3 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = TaxRuleCountryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- TaxRuleCountryPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Country) to the collection in $obj3 (TaxRuleCountry)
- $obj1->setTaxRuleCountry($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related CountryDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptCountryDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CountryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CountryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CountryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CountryPeer::ID, TaxRuleCountryPeer::COUNTRY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxRuleCountry table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptTaxRuleCountry(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CountryPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CountryPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CountryPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CountryPeer::ID, CountryDescPeer::COUNTRY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Country objects pre-filled with all related objects except CountryDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Country objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptCountryDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CountryPeer::DATABASE_NAME);
- }
-
- CountryPeer::addSelectColumns($criteria);
- $startcol2 = CountryPeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleCountryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CountryPeer::ID, TaxRuleCountryPeer::COUNTRY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CountryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CountryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CountryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CountryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined TaxRuleCountry rows
-
- $key2 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = TaxRuleCountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- TaxRuleCountryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Country) to the collection in $obj2 (TaxRuleCountry)
- $obj1->setTaxRuleCountry($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Country objects pre-filled with all related objects except TaxRuleCountry.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Country objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptTaxRuleCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CountryPeer::DATABASE_NAME);
- }
-
- CountryPeer::addSelectColumns($criteria);
- $startcol2 = CountryPeer::NUM_HYDRATE_COLUMNS;
-
- CountryDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CountryDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CountryPeer::ID, CountryDescPeer::COUNTRY_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CountryPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CountryPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CountryPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CountryPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined CountryDesc rows
-
- $key2 = CountryDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = CountryDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CountryDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- CountryDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Country) to the collection in $obj2 (CountryDesc)
- $obj1->setCountryDesc($obj2);
-
- } // if joined row is not null
-
$results[] = $obj1;
}
$stmt->closeCursor();
@@ -1256,7 +864,6 @@ abstract class BaseCountryPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- CountryPeer::doOnDeleteSetNull(new Criteria(CountryPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CountryPeer::TABLE_NAME, $con, CountryPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -1290,14 +897,24 @@ abstract class BaseCountryPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CountryPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Country) { // it's a model object
+ // invalidate the cache for this single object
+ CountryPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CountryPeer::DATABASE_NAME);
$criteria->add(CountryPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CountryPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -1310,23 +927,6 @@ abstract class BaseCountryPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- CountryPeer::doOnDeleteSetNull($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- CountryPeer::clearInstancePool();
- } elseif ($values instanceof Country) { // it's a model object
- CountryPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- CountryPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
CountryPeer::clearRelatedInstancePool();
$con->commit();
@@ -1338,37 +938,6 @@ abstract class BaseCountryPeer
}
}
- /**
- * This is a method for emulating ON DELETE SET NULL DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return void
- */
- protected static function doOnDeleteSetNull(Criteria $criteria, PropelPDO $con)
- {
-
- // first find the objects that are implicated by the $criteria
- $objects = CountryPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
- // set fkey col in related Area rows to null
- $selectCriteria = new Criteria(CountryPeer::DATABASE_NAME);
- $updateValues = new Criteria(CountryPeer::DATABASE_NAME);
- $selectCriteria->add(AreaPeer::ID, $obj->getAreaId());
- $updateValues->add(AreaPeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- }
- }
-
/**
* Validates all modified columns of given Country object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseCountryQuery.php b/core/lib/Thelia/Model/om/BaseCountryQuery.php
index aabc13b55..27500b9fd 100644
--- a/core/lib/Thelia/Model/om/BaseCountryQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCountryQuery.php
@@ -44,6 +44,10 @@ use Thelia\Model\TaxRuleCountry;
* @method CountryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method CountryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
+ * @method CountryQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation
+ * @method CountryQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation
+ * @method CountryQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation
+ *
* @method CountryQuery leftJoinCountryDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the CountryDesc relation
* @method CountryQuery rightJoinCountryDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CountryDesc relation
* @method CountryQuery innerJoinCountryDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the CountryDesc relation
@@ -52,10 +56,6 @@ use Thelia\Model\TaxRuleCountry;
* @method CountryQuery rightJoinTaxRuleCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRuleCountry relation
* @method CountryQuery innerJoinTaxRuleCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRuleCountry relation
*
- * @method CountryQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation
- * @method CountryQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation
- * @method CountryQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation
- *
* @method Country findOne(PropelPDO $con = null) Return the first Country matching the query
* @method Country findOneOrCreate(PropelPDO $con = null) Return the first Country matching the query, or a new Country object populated from the query conditions when no match is found
*
@@ -86,7 +86,7 @@ abstract class BaseCountryQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Country', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Country', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -262,10 +262,6 @@ abstract class BaseCountryQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByCountryDesc()
- *
- * @see filterByTaxRuleCountry()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -293,6 +289,8 @@ abstract class BaseCountryQuery extends ModelCriteria
* $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12
*
*
+ * @see filterByArea()
+ *
* @param mixed $areaId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -497,10 +495,86 @@ abstract class BaseCountryQuery extends ModelCriteria
return $this->addUsingAlias(CountryPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query by a related Area object
+ *
+ * @param Area|PropelObjectCollection $area The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByArea($area, $comparison = null)
+ {
+ if ($area instanceof Area) {
+ return $this
+ ->addUsingAlias(CountryPeer::AREA_ID, $area->getId(), $comparison);
+ } elseif ($area instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CountryPeer::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByArea() only accepts arguments of type Area or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Area relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Area');
+
+ // 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, 'Area');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Area relation Area 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\AreaQuery A secondary query class using the current class as primary query
+ */
+ public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinArea($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery');
+ }
+
/**
* Filter the query by a related CountryDesc object
*
- * @param CountryDesc|PropelObjectCollection $countryDesc The related object(s) to use as filter
+ * @param CountryDesc|PropelObjectCollection $countryDesc the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CountryQuery The current query, for fluid interface
@@ -512,12 +586,10 @@ abstract class BaseCountryQuery extends ModelCriteria
return $this
->addUsingAlias(CountryPeer::ID, $countryDesc->getCountryId(), $comparison);
} elseif ($countryDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CountryPeer::ID, $countryDesc->toKeyValue('PrimaryKey', 'CountryId'), $comparison);
+ ->useCountryDescQuery()
+ ->filterByPrimaryKeys($countryDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByCountryDesc() only accepts arguments of type CountryDesc or PropelCollection');
}
@@ -576,7 +648,7 @@ abstract class BaseCountryQuery extends ModelCriteria
/**
* Filter the query by a related TaxRuleCountry object
*
- * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry The related object(s) to use as filter
+ * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CountryQuery The current query, for fluid interface
@@ -588,12 +660,10 @@ abstract class BaseCountryQuery extends ModelCriteria
return $this
->addUsingAlias(CountryPeer::ID, $taxRuleCountry->getCountryId(), $comparison);
} elseif ($taxRuleCountry instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CountryPeer::ID, $taxRuleCountry->toKeyValue('PrimaryKey', 'CountryId'), $comparison);
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection');
}
@@ -607,7 +677,7 @@ abstract class BaseCountryQuery extends ModelCriteria
*
* @return CountryQuery The current query, for fluid interface
*/
- public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('TaxRuleCountry');
@@ -642,87 +712,13 @@ abstract class BaseCountryQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
*/
- public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ 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 Area object
- *
- * @param Area|PropelObjectCollection $area the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return CountryQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByArea($area, $comparison = null)
- {
- if ($area instanceof Area) {
- return $this
- ->addUsingAlias(CountryPeer::AREA_ID, $area->getId(), $comparison);
- } elseif ($area instanceof PropelObjectCollection) {
- return $this
- ->useAreaQuery()
- ->filterByPrimaryKeys($area->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByArea() only accepts arguments of type Area or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Area relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return CountryQuery The current query, for fluid interface
- */
- public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Area');
-
- // 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, 'Area');
- }
-
- return $this;
- }
-
- /**
- * Use the Area relation Area 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\AreaQuery A secondary query class using the current class as primary query
- */
- public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinArea($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery');
- }
-
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseCoupon.php b/core/lib/Thelia/Model/om/BaseCoupon.php
index 0ac37420d..6f2d237c2 100644
--- a/core/lib/Thelia/Model/om/BaseCoupon.php
+++ b/core/lib/Thelia/Model/om/BaseCoupon.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Coupon;
use Thelia\Model\CouponPeer;
@@ -108,9 +110,10 @@ abstract class BaseCoupon extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var CouponRule
+ * @var PropelObjectCollection|CouponRule[] Collection to store aggregation of CouponRule objects.
*/
- protected $aCouponRule;
+ protected $collCouponRules;
+ protected $collCouponRulesPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -126,6 +129,12 @@ abstract class BaseCoupon extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $couponRulesScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -351,10 +360,6 @@ abstract class BaseCoupon extends BaseObject implements Persistent
$this->modifiedColumns[] = CouponPeer::ID;
}
- if ($this->aCouponRule !== null && $this->aCouponRule->getCouponId() !== $v) {
- $this->aCouponRule = null;
- }
-
return $this;
} // setId()
@@ -629,9 +634,6 @@ abstract class BaseCoupon extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aCouponRule !== null && $this->id !== $this->aCouponRule->getCouponId()) {
- $this->aCouponRule = null;
- }
} // ensureConsistency
/**
@@ -671,7 +673,8 @@ abstract class BaseCoupon extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aCouponRule = null;
+ $this->collCouponRules = null;
+
} // if (deep)
}
@@ -785,18 +788,6 @@ abstract class BaseCoupon extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aCouponRule !== null) {
- if ($this->aCouponRule->isModified() || $this->aCouponRule->isNew()) {
- $affectedRows += $this->aCouponRule->save($con);
- }
- $this->setCouponRule($this->aCouponRule);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -808,6 +799,23 @@ abstract class BaseCoupon extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->couponRulesScheduledForDeletion !== null) {
+ if (!$this->couponRulesScheduledForDeletion->isEmpty()) {
+ CouponRuleQuery::create()
+ ->filterByPrimaryKeys($this->couponRulesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->couponRulesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCouponRules !== null) {
+ foreach ($this->collCouponRules as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -999,23 +1007,19 @@ abstract class BaseCoupon extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aCouponRule !== null) {
- if (!$this->aCouponRule->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aCouponRule->getValidationFailures());
- }
- }
-
-
if (($retval = CouponPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collCouponRules !== null) {
+ foreach ($this->collCouponRules as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1122,8 +1126,8 @@ abstract class BaseCoupon extends BaseObject implements Persistent
$keys[9] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aCouponRule) {
- $result['CouponRule'] = $this->aCouponRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collCouponRules) {
+ $result['CouponRules'] = $this->collCouponRules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1324,9 +1328,10 @@ abstract class BaseCoupon extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCouponRule();
- if ($relObj) {
- $copyObj->setCouponRule($relObj->copy($deepCopy));
+ foreach ($this->getCouponRules() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCouponRule($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1379,51 +1384,227 @@ abstract class BaseCoupon extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a CouponRule object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param CouponRule $v
- * @return Coupon The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CouponRule' == $relationName) {
+ $this->initCouponRules();
+ }
+ }
+
+ /**
+ * Clears out the collCouponRules 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 addCouponRules()
+ */
+ public function clearCouponRules()
+ {
+ $this->collCouponRules = null; // important to set this to null since that means it is uninitialized
+ $this->collCouponRulesPartial = null;
+ }
+
+ /**
+ * reset is the collCouponRules collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialCouponRules($v = true)
+ {
+ $this->collCouponRulesPartial = $v;
+ }
+
+ /**
+ * Initializes the collCouponRules collection.
+ *
+ * By default this just sets the collCouponRules collection to an empty array (like clearcollCouponRules());
+ * 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 initCouponRules($overrideExisting = true)
+ {
+ if (null !== $this->collCouponRules && !$overrideExisting) {
+ return;
+ }
+ $this->collCouponRules = new PropelObjectCollection();
+ $this->collCouponRules->setModel('CouponRule');
+ }
+
+ /**
+ * Gets an array of CouponRule 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 Coupon 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|CouponRule[] List of CouponRule objects
* @throws PropelException
*/
- public function setCouponRule(CouponRule $v = null)
+ public function getCouponRules($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collCouponRulesPartial && !$this->isNew();
+ if (null === $this->collCouponRules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCouponRules) {
+ // return empty collection
+ $this->initCouponRules();
+ } else {
+ $collCouponRules = CouponRuleQuery::create(null, $criteria)
+ ->filterByCoupon($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCouponRulesPartial && count($collCouponRules)) {
+ $this->initCouponRules(false);
+
+ foreach($collCouponRules as $obj) {
+ if (false == $this->collCouponRules->contains($obj)) {
+ $this->collCouponRules->append($obj);
+ }
+ }
+
+ $this->collCouponRulesPartial = true;
+ }
+
+ return $collCouponRules;
+ }
+
+ if($partial && $this->collCouponRules) {
+ foreach($this->collCouponRules as $obj) {
+ if($obj->isNew()) {
+ $collCouponRules[] = $obj;
+ }
+ }
+ }
+
+ $this->collCouponRules = $collCouponRules;
+ $this->collCouponRulesPartial = false;
+ }
+ }
+
+ return $this->collCouponRules;
+ }
+
+ /**
+ * Sets a collection of CouponRule 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 $couponRules A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setCouponRules(PropelCollection $couponRules, PropelPDO $con = null)
+ {
+ $this->couponRulesScheduledForDeletion = $this->getCouponRules(new Criteria(), $con)->diff($couponRules);
+
+ foreach ($this->couponRulesScheduledForDeletion as $couponRuleRemoved) {
+ $couponRuleRemoved->setCoupon(null);
+ }
+
+ $this->collCouponRules = null;
+ foreach ($couponRules as $couponRule) {
+ $this->addCouponRule($couponRule);
+ }
+
+ $this->collCouponRules = $couponRules;
+ $this->collCouponRulesPartial = false;
+ }
+
+ /**
+ * Returns the number of related CouponRule objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CouponRule objects.
+ * @throws PropelException
+ */
+ public function countCouponRules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCouponRulesPartial && !$this->isNew();
+ if (null === $this->collCouponRules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCouponRules) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getCouponRules());
+ }
+ $query = CouponRuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCoupon($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCouponId());
+ return count($this->collCouponRules);
}
+ }
- $this->aCouponRule = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCoupon($this);
+ /**
+ * Method called to associate a CouponRule object to this object
+ * through the CouponRule foreign key attribute.
+ *
+ * @param CouponRule $l CouponRule
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function addCouponRule(CouponRule $l)
+ {
+ if ($this->collCouponRules === null) {
+ $this->initCouponRules();
+ $this->collCouponRulesPartial = true;
+ }
+ if (!$this->collCouponRules->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddCouponRule($l);
}
-
return $this;
}
+ /**
+ * @param CouponRule $couponRule The couponRule object to add.
+ */
+ protected function doAddCouponRule($couponRule)
+ {
+ $this->collCouponRules[]= $couponRule;
+ $couponRule->setCoupon($this);
+ }
/**
- * Get the associated CouponRule object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return CouponRule The associated CouponRule object.
- * @throws PropelException
+ * @param CouponRule $couponRule The couponRule object to remove.
*/
- public function getCouponRule(PropelPDO $con = null)
+ public function removeCouponRule($couponRule)
{
- if ($this->aCouponRule === null && ($this->id !== null)) {
- $this->aCouponRule = CouponRuleQuery::create()
- ->filterByCoupon($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aCouponRule->setCoupon($this);
+ if ($this->getCouponRules()->contains($couponRule)) {
+ $this->collCouponRules->remove($this->collCouponRules->search($couponRule));
+ if (null === $this->couponRulesScheduledForDeletion) {
+ $this->couponRulesScheduledForDeletion = clone $this->collCouponRules;
+ $this->couponRulesScheduledForDeletion->clear();
+ }
+ $this->couponRulesScheduledForDeletion[]= $couponRule;
+ $couponRule->setCoupon(null);
}
-
- return $this->aCouponRule;
}
/**
@@ -1461,9 +1642,17 @@ abstract class BaseCoupon extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collCouponRules) {
+ foreach ($this->collCouponRules as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aCouponRule = null;
+ if ($this->collCouponRules instanceof PropelCollection) {
+ $this->collCouponRules->clearIterator();
+ }
+ $this->collCouponRules = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCouponOrder.php b/core/lib/Thelia/Model/om/BaseCouponOrder.php
index 5d667f293..296fd0e6a 100644
--- a/core/lib/Thelia/Model/om/BaseCouponOrder.php
+++ b/core/lib/Thelia/Model/om/BaseCouponOrder.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\CouponOrder;
use Thelia\Model\CouponOrderPeer;
@@ -86,9 +84,9 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Order one-to-one related Order object
+ * @var Order
*/
- protected $singleOrder;
+ protected $aOrder;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -104,12 +102,6 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $ordersScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -262,6 +254,10 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
$this->modifiedColumns[] = CouponOrderPeer::ORDER_ID;
}
+ if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
+ $this->aOrder = null;
+ }
+
return $this;
} // setOrderId()
@@ -423,6 +419,9 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) {
+ $this->aOrder = null;
+ }
} // ensureConsistency
/**
@@ -462,8 +461,7 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleOrder = null;
-
+ $this->aOrder = null;
} // if (deep)
}
@@ -577,6 +575,18 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrder !== null) {
+ if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
+ $affectedRows += $this->aOrder->save($con);
+ }
+ $this->setOrder($this->aOrder);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -588,21 +598,6 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->ordersScheduledForDeletion !== null) {
- if (!$this->ordersScheduledForDeletion->isEmpty()) {
- OrderQuery::create()
- ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->ordersScheduledForDeletion = null;
- }
- }
-
- if ($this->singleOrder !== null) {
- if (!$this->singleOrder->isDeleted()) {
- $affectedRows += $this->singleOrder->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -770,17 +765,23 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrder !== null) {
+ if (!$this->aOrder->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
+ }
+ }
+
+
if (($retval = CouponOrderPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleOrder !== null) {
- if (!$this->singleOrder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleOrder->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -871,8 +872,8 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
$keys[5] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleOrder) {
- $result['Order'] = $this->singleOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aOrder) {
+ $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1049,11 +1050,6 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getOrder();
- if ($relObj) {
- $copyObj->setOrder($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1104,55 +1100,57 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Order object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Order object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Order
- * @throws PropelException
- */
- public function getOrder(PropelPDO $con = null)
- {
-
- if ($this->singleOrder === null && !$this->isNew()) {
- $this->singleOrder = OrderQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleOrder;
- }
-
- /**
- * Sets a single Order object as related to this object by a one-to-one relationship.
- *
- * @param Order $v Order
+ * @param Order $v
* @return CouponOrder The current object (for fluent API support)
* @throws PropelException
*/
public function setOrder(Order $v = null)
{
- $this->singleOrder = $v;
-
- // Make sure that that the passed-in Order isn't already associated with this object
- if ($v !== null && $v->getCouponOrder() === null) {
- $v->setCouponOrder($this);
+ if ($v === null) {
+ $this->setOrderId(NULL);
+ } else {
+ $this->setOrderId($v->getId());
}
+ $this->aOrder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Order object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCouponOrder($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Order object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Order The associated Order object.
+ * @throws PropelException
+ */
+ public function getOrder(PropelPDO $con = null)
+ {
+ if ($this->aOrder === null && ($this->order_id !== null)) {
+ $this->aOrder = OrderQuery::create()->findPk($this->order_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->aOrder->addCouponOrders($this);
+ */
+ }
+
+ return $this->aOrder;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1184,15 +1182,9 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleOrder) {
- $this->singleOrder->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleOrder instanceof PropelCollection) {
- $this->singleOrder->clearIterator();
- }
- $this->singleOrder = null;
+ $this->aOrder = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php b/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php
index ce764ed97..30b8f5429 100644
--- a/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php
@@ -25,7 +25,7 @@ abstract class BaseCouponOrderPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'coupon_order';
@@ -388,9 +388,6 @@ abstract class BaseCouponOrderPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in OrderPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- OrderPeer::clearInstancePool();
}
/**
@@ -487,6 +484,244 @@ abstract class BaseCouponOrderPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Order table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinOrder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CouponOrderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CouponOrderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CouponOrderPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of CouponOrder objects pre-filled with their Order objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CouponOrder objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME);
+ }
+
+ CouponOrderPeer::addSelectColumns($criteria);
+ $startcol = CouponOrderPeer::NUM_HYDRATE_COLUMNS;
+ OrderPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CouponOrderPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CouponOrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CouponOrderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = CouponOrderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CouponOrderPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = OrderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ OrderPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (CouponOrder) to $obj2 (Order)
+ $obj2->addCouponOrder($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CouponOrderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CouponOrderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CouponOrderPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of CouponOrder objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CouponOrder objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME);
+ }
+
+ CouponOrderPeer::addSelectColumns($criteria);
+ $startcol2 = CouponOrderPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CouponOrderPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CouponOrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CouponOrderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = CouponOrderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CouponOrderPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Order rows
+
+ $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = OrderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ OrderPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (CouponOrder) to the collection in $obj2 (Order)
+ $obj2->addCouponOrder($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -620,7 +855,6 @@ abstract class BaseCouponOrderPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += CouponOrderPeer::doOnDeleteCascade(new Criteria(CouponOrderPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CouponOrderPeer::TABLE_NAME, $con, CouponOrderPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -654,14 +888,24 @@ abstract class BaseCouponOrderPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CouponOrderPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CouponOrder) { // it's a model object
+ // invalidate the cache for this single object
+ CouponOrderPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CouponOrderPeer::DATABASE_NAME);
$criteria->add(CouponOrderPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CouponOrderPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -674,23 +918,6 @@ abstract class BaseCouponOrderPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += CouponOrderPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- CouponOrderPeer::clearInstancePool();
- } elseif ($values instanceof CouponOrder) { // it's a model object
- CouponOrderPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- CouponOrderPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
CouponOrderPeer::clearRelatedInstancePool();
$con->commit();
@@ -702,39 +929,6 @@ abstract class BaseCouponOrderPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = CouponOrderPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Order objects
- $criteria = new Criteria(OrderPeer::DATABASE_NAME);
-
- $criteria->add(OrderPeer::ID, $obj->getOrderId());
- $affectedRows += OrderPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given CouponOrder object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php
index bab6e0c05..c0e40c227 100644
--- a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php
@@ -72,7 +72,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\CouponOrder', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\CouponOrder', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -275,6 +275,8 @@ abstract class BaseCouponOrderQuery extends ModelCriteria
* $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
*
*
+ * @see filterByOrder()
+ *
* @param mixed $orderId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -465,7 +467,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria
/**
* Filter the query by a related Order object
*
- * @param Order|PropelObjectCollection $order the related object to use as filter
+ * @param Order|PropelObjectCollection $order The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CouponOrderQuery The current query, for fluid interface
@@ -477,10 +479,12 @@ abstract class BaseCouponOrderQuery extends ModelCriteria
return $this
->addUsingAlias(CouponOrderPeer::ORDER_ID, $order->getId(), $comparison);
} elseif ($order instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useOrderQuery()
- ->filterByPrimaryKeys($order->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(CouponOrderPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseCouponPeer.php b/core/lib/Thelia/Model/om/BaseCouponPeer.php
index 1f615348d..dcc446f3c 100644
--- a/core/lib/Thelia/Model/om/BaseCouponPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCouponPeer.php
@@ -25,7 +25,7 @@ abstract class BaseCouponPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'coupon';
@@ -408,6 +408,9 @@ abstract class BaseCouponPeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in CouponRulePeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CouponRulePeer::clearInstancePool();
}
/**
@@ -504,245 +507,6 @@ abstract class BaseCouponPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related CouponRule table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinCouponRule(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CouponPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CouponPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CouponPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CouponPeer::ID, CouponRulePeer::COUPON_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Coupon objects pre-filled with their CouponRule objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Coupon objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinCouponRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CouponPeer::DATABASE_NAME);
- }
-
- CouponPeer::addSelectColumns($criteria);
- $startcol = CouponPeer::NUM_HYDRATE_COLUMNS;
- CouponRulePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CouponPeer::ID, CouponRulePeer::COUPON_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CouponPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CouponPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CouponPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CouponPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = CouponRulePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = CouponRulePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CouponRulePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- CouponRulePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Coupon) to $obj2 (CouponRule)
- // one to one relationship
- $obj1->setCouponRule($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CouponPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CouponPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CouponPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CouponPeer::ID, CouponRulePeer::COUPON_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Coupon objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Coupon objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CouponPeer::DATABASE_NAME);
- }
-
- CouponPeer::addSelectColumns($criteria);
- $startcol2 = CouponPeer::NUM_HYDRATE_COLUMNS;
-
- CouponRulePeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CouponRulePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CouponPeer::ID, CouponRulePeer::COUPON_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CouponPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CouponPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CouponPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CouponPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined CouponRule rows
-
- $key2 = CouponRulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = CouponRulePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CouponRulePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- CouponRulePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Coupon) to the collection in $obj2 (CouponRule)
- $obj1->setCouponRule($obj2);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseCouponQuery.php b/core/lib/Thelia/Model/om/BaseCouponQuery.php
index 852ccf292..267f44074 100644
--- a/core/lib/Thelia/Model/om/BaseCouponQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCouponQuery.php
@@ -88,7 +88,7 @@ abstract class BaseCouponQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Coupon', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Coupon', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -264,8 +264,6 @@ abstract class BaseCouponQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByCouponRule()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -639,7 +637,7 @@ abstract class BaseCouponQuery extends ModelCriteria
/**
* Filter the query by a related CouponRule object
*
- * @param CouponRule|PropelObjectCollection $couponRule The related object(s) to use as filter
+ * @param CouponRule|PropelObjectCollection $couponRule the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CouponQuery The current query, for fluid interface
@@ -651,12 +649,10 @@ abstract class BaseCouponQuery extends ModelCriteria
return $this
->addUsingAlias(CouponPeer::ID, $couponRule->getCouponId(), $comparison);
} elseif ($couponRule instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CouponPeer::ID, $couponRule->toKeyValue('PrimaryKey', 'CouponId'), $comparison);
+ ->useCouponRuleQuery()
+ ->filterByPrimaryKeys($couponRule->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByCouponRule() only accepts arguments of type CouponRule or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseCouponRule.php b/core/lib/Thelia/Model/om/BaseCouponRule.php
index 886dfd3fd..0a06eef8b 100644
--- a/core/lib/Thelia/Model/om/BaseCouponRule.php
+++ b/core/lib/Thelia/Model/om/BaseCouponRule.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Coupon;
use Thelia\Model\CouponQuery;
@@ -92,9 +90,9 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Coupon one-to-one related Coupon object
+ * @var Coupon
*/
- protected $singleCoupon;
+ protected $aCoupon;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -110,12 +108,6 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $couponsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -278,6 +270,10 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
$this->modifiedColumns[] = CouponRulePeer::COUPON_ID;
}
+ if ($this->aCoupon !== null && $this->aCoupon->getId() !== $v) {
+ $this->aCoupon = null;
+ }
+
return $this;
} // setCouponId()
@@ -461,6 +457,9 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aCoupon !== null && $this->coupon_id !== $this->aCoupon->getId()) {
+ $this->aCoupon = null;
+ }
} // ensureConsistency
/**
@@ -500,8 +499,7 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCoupon = null;
-
+ $this->aCoupon = null;
} // if (deep)
}
@@ -615,6 +613,18 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCoupon !== null) {
+ if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) {
+ $affectedRows += $this->aCoupon->save($con);
+ }
+ $this->setCoupon($this->aCoupon);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -626,21 +636,6 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->couponsScheduledForDeletion !== null) {
- if (!$this->couponsScheduledForDeletion->isEmpty()) {
- CouponQuery::create()
- ->filterByPrimaryKeys($this->couponsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->couponsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCoupon !== null) {
- if (!$this->singleCoupon->isDeleted()) {
- $affectedRows += $this->singleCoupon->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -814,17 +809,23 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCoupon !== null) {
+ if (!$this->aCoupon->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCoupon->getValidationFailures());
+ }
+ }
+
+
if (($retval = CouponRulePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCoupon !== null) {
- if (!$this->singleCoupon->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCoupon->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -919,8 +920,8 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCoupon) {
- $result['Coupon'] = $this->singleCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCoupon) {
+ $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1103,11 +1104,6 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCoupon();
- if ($relObj) {
- $copyObj->setCoupon($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1158,55 +1154,57 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Coupon object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Coupon object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Coupon
- * @throws PropelException
- */
- public function getCoupon(PropelPDO $con = null)
- {
-
- if ($this->singleCoupon === null && !$this->isNew()) {
- $this->singleCoupon = CouponQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCoupon;
- }
-
- /**
- * Sets a single Coupon object as related to this object by a one-to-one relationship.
- *
- * @param Coupon $v Coupon
+ * @param Coupon $v
* @return CouponRule The current object (for fluent API support)
* @throws PropelException
*/
public function setCoupon(Coupon $v = null)
{
- $this->singleCoupon = $v;
-
- // Make sure that that the passed-in Coupon isn't already associated with this object
- if ($v !== null && $v->getCouponRule() === null) {
- $v->setCouponRule($this);
+ if ($v === null) {
+ $this->setCouponId(NULL);
+ } else {
+ $this->setCouponId($v->getId());
}
+ $this->aCoupon = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Coupon object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCouponRule($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Coupon object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Coupon The associated Coupon object.
+ * @throws PropelException
+ */
+ public function getCoupon(PropelPDO $con = null)
+ {
+ if ($this->aCoupon === null && ($this->coupon_id !== null)) {
+ $this->aCoupon = CouponQuery::create()->findPk($this->coupon_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->aCoupon->addCouponRules($this);
+ */
+ }
+
+ return $this->aCoupon;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1239,15 +1237,9 @@ abstract class BaseCouponRule extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCoupon) {
- $this->singleCoupon->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCoupon instanceof PropelCollection) {
- $this->singleCoupon->clearIterator();
- }
- $this->singleCoupon = null;
+ $this->aCoupon = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCouponRulePeer.php b/core/lib/Thelia/Model/om/BaseCouponRulePeer.php
index 29eed618d..85d9c6c0b 100644
--- a/core/lib/Thelia/Model/om/BaseCouponRulePeer.php
+++ b/core/lib/Thelia/Model/om/BaseCouponRulePeer.php
@@ -25,7 +25,7 @@ abstract class BaseCouponRulePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'coupon_rule';
@@ -393,9 +393,6 @@ abstract class BaseCouponRulePeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CouponPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CouponPeer::clearInstancePool();
}
/**
@@ -492,6 +489,244 @@ abstract class BaseCouponRulePeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Coupon table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCoupon(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CouponRulePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CouponRulePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CouponRulePeer::COUPON_ID, CouponPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of CouponRule objects pre-filled with their Coupon objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CouponRule objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCoupon(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME);
+ }
+
+ CouponRulePeer::addSelectColumns($criteria);
+ $startcol = CouponRulePeer::NUM_HYDRATE_COLUMNS;
+ CouponPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CouponRulePeer::COUPON_ID, CouponPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CouponRulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CouponRulePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = CouponRulePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CouponRulePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CouponPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CouponPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CouponPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CouponPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (CouponRule) to $obj2 (Coupon)
+ $obj2->addCouponRule($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CouponRulePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CouponRulePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CouponRulePeer::COUPON_ID, CouponPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of CouponRule objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CouponRule objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME);
+ }
+
+ CouponRulePeer::addSelectColumns($criteria);
+ $startcol2 = CouponRulePeer::NUM_HYDRATE_COLUMNS;
+
+ CouponPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CouponPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CouponRulePeer::COUPON_ID, CouponPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CouponRulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CouponRulePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = CouponRulePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CouponRulePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Coupon rows
+
+ $key2 = CouponPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CouponPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CouponPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CouponPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (CouponRule) to the collection in $obj2 (Coupon)
+ $obj2->addCouponRule($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -625,7 +860,6 @@ abstract class BaseCouponRulePeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += CouponRulePeer::doOnDeleteCascade(new Criteria(CouponRulePeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CouponRulePeer::TABLE_NAME, $con, CouponRulePeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -659,14 +893,24 @@ abstract class BaseCouponRulePeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CouponRulePeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CouponRule) { // it's a model object
+ // invalidate the cache for this single object
+ CouponRulePeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CouponRulePeer::DATABASE_NAME);
$criteria->add(CouponRulePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CouponRulePeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -679,23 +923,6 @@ abstract class BaseCouponRulePeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += CouponRulePeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- CouponRulePeer::clearInstancePool();
- } elseif ($values instanceof CouponRule) { // it's a model object
- CouponRulePeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- CouponRulePeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
CouponRulePeer::clearRelatedInstancePool();
$con->commit();
@@ -707,39 +934,6 @@ abstract class BaseCouponRulePeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = CouponRulePeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Coupon objects
- $criteria = new Criteria(CouponPeer::DATABASE_NAME);
-
- $criteria->add(CouponPeer::ID, $obj->getCouponId());
- $affectedRows += CouponPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given CouponRule object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php
index d09cfe2be..39d5e507e 100644
--- a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php
@@ -76,7 +76,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\CouponRule', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\CouponRule', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -279,6 +279,8 @@ abstract class BaseCouponRuleQuery extends ModelCriteria
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
*
*
+ * @see filterByCoupon()
+ *
* @param mixed $couponId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -498,7 +500,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria
/**
* Filter the query by a related Coupon object
*
- * @param Coupon|PropelObjectCollection $coupon the related object to use as filter
+ * @param Coupon|PropelObjectCollection $coupon The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CouponRuleQuery The current query, for fluid interface
@@ -510,10 +512,12 @@ abstract class BaseCouponRuleQuery extends ModelCriteria
return $this
->addUsingAlias(CouponRulePeer::COUPON_ID, $coupon->getId(), $comparison);
} elseif ($coupon instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCouponQuery()
- ->filterByPrimaryKeys($coupon->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(CouponRulePeer::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCoupon() only accepts arguments of type Coupon or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseCurrency.php b/core/lib/Thelia/Model/om/BaseCurrency.php
index 5c1473128..2f143f6fd 100644
--- a/core/lib/Thelia/Model/om/BaseCurrency.php
+++ b/core/lib/Thelia/Model/om/BaseCurrency.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Currency;
use Thelia\Model\CurrencyPeer;
@@ -96,9 +98,10 @@ abstract class BaseCurrency extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Order
+ * @var PropelObjectCollection|Order[] Collection to store aggregation of Order objects.
*/
- protected $aOrder;
+ protected $collOrders;
+ protected $collOrdersPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -114,6 +117,12 @@ abstract class BaseCurrency extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $ordersScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -265,10 +274,6 @@ abstract class BaseCurrency extends BaseObject implements Persistent
$this->modifiedColumns[] = CurrencyPeer::ID;
}
- if ($this->aOrder !== null && $this->aOrder->getCurrencyId() !== $v) {
- $this->aOrder = null;
- }
-
return $this;
} // setId()
@@ -495,9 +500,6 @@ abstract class BaseCurrency extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aOrder !== null && $this->id !== $this->aOrder->getCurrencyId()) {
- $this->aOrder = null;
- }
} // ensureConsistency
/**
@@ -537,7 +539,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aOrder = null;
+ $this->collOrders = null;
+
} // if (deep)
}
@@ -651,18 +654,6 @@ abstract class BaseCurrency extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aOrder !== null) {
- if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
- $affectedRows += $this->aOrder->save($con);
- }
- $this->setOrder($this->aOrder);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -674,6 +665,24 @@ abstract class BaseCurrency extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->ordersScheduledForDeletion !== null) {
+ if (!$this->ordersScheduledForDeletion->isEmpty()) {
+ foreach ($this->ordersScheduledForDeletion as $order) {
+ // need to save related object because we set the relation to null
+ $order->save($con);
+ }
+ $this->ordersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -853,23 +862,19 @@ abstract class BaseCurrency extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aOrder !== null) {
- if (!$this->aOrder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
- }
- }
-
-
if (($retval = CurrencyPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -968,8 +973,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aOrder) {
- $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1158,9 +1163,10 @@ abstract class BaseCurrency extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getOrder();
- if ($relObj) {
- $copyObj->setOrder($relObj->copy($deepCopy));
+ foreach ($this->getOrders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrder($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1213,51 +1219,327 @@ abstract class BaseCurrency extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a Order object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param Order $v
- * @return Currency The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Order' == $relationName) {
+ $this->initOrders();
+ }
+ }
+
+ /**
+ * Clears out the collOrders 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 addOrders()
+ */
+ public function clearOrders()
+ {
+ $this->collOrders = null; // important to set this to null since that means it is uninitialized
+ $this->collOrdersPartial = null;
+ }
+
+ /**
+ * reset is the collOrders collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialOrders($v = true)
+ {
+ $this->collOrdersPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrders collection.
+ *
+ * By default this just sets the collOrders collection to an empty array (like clearcollOrders());
+ * 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 initOrders($overrideExisting = true)
+ {
+ if (null !== $this->collOrders && !$overrideExisting) {
+ return;
+ }
+ $this->collOrders = new PropelObjectCollection();
+ $this->collOrders->setModel('Order');
+ }
+
+ /**
+ * Gets an array of Order 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 Currency 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|Order[] List of Order objects
* @throws PropelException
*/
- public function setOrder(Order $v = null)
+ public function getOrders($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ // return empty collection
+ $this->initOrders();
+ } else {
+ $collOrders = OrderQuery::create(null, $criteria)
+ ->filterByCurrency($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersPartial && count($collOrders)) {
+ $this->initOrders(false);
+
+ foreach($collOrders as $obj) {
+ if (false == $this->collOrders->contains($obj)) {
+ $this->collOrders->append($obj);
+ }
+ }
+
+ $this->collOrdersPartial = true;
+ }
+
+ return $collOrders;
+ }
+
+ if($partial && $this->collOrders) {
+ foreach($this->collOrders as $obj) {
+ if($obj->isNew()) {
+ $collOrders[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrders = $collOrders;
+ $this->collOrdersPartial = false;
+ }
+ }
+
+ return $this->collOrders;
+ }
+
+ /**
+ * Sets a collection of Order 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 $orders A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setOrders(PropelCollection $orders, PropelPDO $con = null)
+ {
+ $this->ordersScheduledForDeletion = $this->getOrders(new Criteria(), $con)->diff($orders);
+
+ foreach ($this->ordersScheduledForDeletion as $orderRemoved) {
+ $orderRemoved->setCurrency(null);
+ }
+
+ $this->collOrders = null;
+ foreach ($orders as $order) {
+ $this->addOrder($order);
+ }
+
+ $this->collOrders = $orders;
+ $this->collOrdersPartial = false;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getOrders());
+ }
+ $query = OrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCurrency($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCurrencyId());
+ return count($this->collOrders);
}
+ }
- $this->aOrder = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCurrency($this);
+ /**
+ * Method called to associate a Order object to this object
+ * through the Order foreign key attribute.
+ *
+ * @param Order $l Order
+ * @return Currency The current object (for fluent API support)
+ */
+ public function addOrder(Order $l)
+ {
+ if ($this->collOrders === null) {
+ $this->initOrders();
+ $this->collOrdersPartial = true;
+ }
+ if (!$this->collOrders->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddOrder($l);
}
-
return $this;
}
+ /**
+ * @param Order $order The order object to add.
+ */
+ protected function doAddOrder($order)
+ {
+ $this->collOrders[]= $order;
+ $order->setCurrency($this);
+ }
/**
- * Get the associated Order object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Order The associated Order object.
- * @throws PropelException
+ * @param Order $order The order object to remove.
*/
- public function getOrder(PropelPDO $con = null)
+ public function removeOrder($order)
{
- if ($this->aOrder === null && ($this->id !== null)) {
- $this->aOrder = OrderQuery::create()
- ->filterByCurrency($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aOrder->setCurrency($this);
+ if ($this->getOrders()->contains($order)) {
+ $this->collOrders->remove($this->collOrders->search($order));
+ if (null === $this->ordersScheduledForDeletion) {
+ $this->ordersScheduledForDeletion = clone $this->collOrders;
+ $this->ordersScheduledForDeletion->clear();
+ }
+ $this->ordersScheduledForDeletion[]= $order;
+ $order->setCurrency(null);
}
+ }
- return $this->aOrder;
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Currency is new, it will return
+ * an empty collection; or if this Currency has previously
+ * been saved, it will retrieve related Orders 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 Currency.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('Customer', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Currency is new, it will return
+ * an empty collection; or if this Currency has previously
+ * been saved, it will retrieve related Orders 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 Currency.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Currency is new, it will return
+ * an empty collection; or if this Currency has previously
+ * been saved, it will retrieve related Orders 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 Currency.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Currency is new, it will return
+ * an empty collection; or if this Currency has previously
+ * been saved, it will retrieve related Orders 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 Currency.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderStatus', $join_behavior);
+
+ return $this->getOrders($query, $con);
}
/**
@@ -1293,9 +1575,17 @@ abstract class BaseCurrency extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collOrders) {
+ foreach ($this->collOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aOrder = null;
+ if ($this->collOrders instanceof PropelCollection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php
index e6e4add2d..698b5e9e0 100644
--- a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php
@@ -25,7 +25,7 @@ abstract class BaseCurrencyPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'currency';
@@ -398,6 +398,9 @@ abstract class BaseCurrencyPeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in OrderPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderPeer::clearInstancePool();
}
/**
@@ -494,245 +497,6 @@ abstract class BaseCurrencyPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CurrencyPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CurrencyPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CurrencyPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CurrencyPeer::ID, OrderPeer::CURRENCY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Currency objects pre-filled with their Order objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Currency objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CurrencyPeer::DATABASE_NAME);
- }
-
- CurrencyPeer::addSelectColumns($criteria);
- $startcol = CurrencyPeer::NUM_HYDRATE_COLUMNS;
- OrderPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CurrencyPeer::ID, OrderPeer::CURRENCY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CurrencyPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CurrencyPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CurrencyPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CurrencyPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Currency) to $obj2 (Order)
- // one to one relationship
- $obj1->setOrder($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CurrencyPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CurrencyPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CurrencyPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CurrencyPeer::ID, OrderPeer::CURRENCY_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Currency objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Currency objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CurrencyPeer::DATABASE_NAME);
- }
-
- CurrencyPeer::addSelectColumns($criteria);
- $startcol2 = CurrencyPeer::NUM_HYDRATE_COLUMNS;
-
- OrderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CurrencyPeer::ID, OrderPeer::CURRENCY_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CurrencyPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CurrencyPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CurrencyPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CurrencyPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Order rows
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Currency) to the collection in $obj2 (Order)
- $obj1->setOrder($obj2);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php
index 8dbb04d0c..e78de4a09 100644
--- a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php
@@ -80,7 +80,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Currency', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Currency', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -256,8 +256,6 @@ abstract class BaseCurrencyQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByOrder()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -533,7 +531,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria
/**
* Filter the query by a related Order object
*
- * @param Order|PropelObjectCollection $order The related object(s) to use as filter
+ * @param Order|PropelObjectCollection $order the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CurrencyQuery The current query, for fluid interface
@@ -545,12 +543,10 @@ abstract class BaseCurrencyQuery extends ModelCriteria
return $this
->addUsingAlias(CurrencyPeer::ID, $order->getCurrencyId(), $comparison);
} elseif ($order instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CurrencyPeer::ID, $order->toKeyValue('PrimaryKey', 'CurrencyId'), $comparison);
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
}
@@ -564,7 +560,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria
*
* @return CurrencyQuery The current query, for fluid interface
*/
- public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Order');
@@ -599,7 +595,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria
*
* @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
*/
- public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinOrder($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseCustomer.php b/core/lib/Thelia/Model/om/BaseCustomer.php
index 7c48289ab..0a9096d5f 100644
--- a/core/lib/Thelia/Model/om/BaseCustomer.php
+++ b/core/lib/Thelia/Model/om/BaseCustomer.php
@@ -198,19 +198,21 @@ abstract class BaseCustomer extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Address
+ * @var CustomerTitle
*/
- protected $aAddress;
+ protected $aCustomerTitle;
/**
- * @var Order
+ * @var PropelObjectCollection|Address[] Collection to store aggregation of Address objects.
*/
- protected $aOrder;
+ protected $collAddresss;
+ protected $collAddresssPartial;
/**
- * @var CustomerTitle one-to-one related CustomerTitle object
+ * @var PropelObjectCollection|Order[] Collection to store aggregation of Order objects.
*/
- protected $singleCustomerTitle;
+ protected $collOrders;
+ protected $collOrdersPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -230,7 +232,13 @@ abstract class BaseCustomer extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $customerTitlesScheduledForDeletion = null;
+ protected $addresssScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $ordersScheduledForDeletion = null;
/**
* Get the [id] column value.
@@ -543,14 +551,6 @@ abstract class BaseCustomer extends BaseObject implements Persistent
$this->modifiedColumns[] = CustomerPeer::ID;
}
- if ($this->aAddress !== null && $this->aAddress->getCustomerId() !== $v) {
- $this->aAddress = null;
- }
-
- if ($this->aOrder !== null && $this->aOrder->getCustomerId() !== $v) {
- $this->aOrder = null;
- }
-
return $this;
} // setId()
@@ -593,6 +593,10 @@ abstract class BaseCustomer extends BaseObject implements Persistent
$this->modifiedColumns[] = CustomerPeer::CUSTOMER_TITLE_ID;
}
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
return $this;
} // setCustomerTitleId()
@@ -1129,11 +1133,8 @@ abstract class BaseCustomer extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAddress !== null && $this->id !== $this->aAddress->getCustomerId()) {
- $this->aAddress = null;
- }
- if ($this->aOrder !== null && $this->id !== $this->aOrder->getCustomerId()) {
- $this->aOrder = null;
+ if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
}
} // ensureConsistency
@@ -1174,9 +1175,10 @@ abstract class BaseCustomer extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAddress = null;
- $this->aOrder = null;
- $this->singleCustomerTitle = null;
+ $this->aCustomerTitle = null;
+ $this->collAddresss = null;
+
+ $this->collOrders = null;
} // if (deep)
}
@@ -1296,18 +1298,11 @@ abstract class BaseCustomer extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aAddress !== null) {
- if ($this->aAddress->isModified() || $this->aAddress->isNew()) {
- $affectedRows += $this->aAddress->save($con);
+ if ($this->aCustomerTitle !== null) {
+ if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
+ $affectedRows += $this->aCustomerTitle->save($con);
}
- $this->setAddress($this->aAddress);
- }
-
- if ($this->aOrder !== null) {
- if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
- $affectedRows += $this->aOrder->save($con);
- }
- $this->setOrder($this->aOrder);
+ $this->setCustomerTitle($this->aCustomerTitle);
}
if ($this->isNew() || $this->isModified()) {
@@ -1321,18 +1316,37 @@ abstract class BaseCustomer extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->customerTitlesScheduledForDeletion !== null) {
- if (!$this->customerTitlesScheduledForDeletion->isEmpty()) {
- CustomerTitleQuery::create()
- ->filterByPrimaryKeys($this->customerTitlesScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->addresssScheduledForDeletion !== null) {
+ if (!$this->addresssScheduledForDeletion->isEmpty()) {
+ AddressQuery::create()
+ ->filterByPrimaryKeys($this->addresssScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->customerTitlesScheduledForDeletion = null;
+ $this->addresssScheduledForDeletion = null;
}
}
- if ($this->singleCustomerTitle !== null) {
- if (!$this->singleCustomerTitle->isDeleted()) {
- $affectedRows += $this->singleCustomerTitle->save($con);
+ if ($this->collAddresss !== null) {
+ foreach ($this->collAddresss as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->ordersScheduledForDeletion !== null) {
+ if (!$this->ordersScheduledForDeletion->isEmpty()) {
+ OrderQuery::create()
+ ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->ordersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
}
}
@@ -1616,15 +1630,9 @@ abstract class BaseCustomer extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aAddress !== null) {
- if (!$this->aAddress->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAddress->getValidationFailures());
- }
- }
-
- if ($this->aOrder !== null) {
- if (!$this->aOrder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
+ if ($this->aCustomerTitle !== null) {
+ if (!$this->aCustomerTitle->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCustomerTitle->getValidationFailures());
}
}
@@ -1634,9 +1642,19 @@ abstract class BaseCustomer extends BaseObject implements Persistent
}
- if ($this->singleCustomerTitle !== null) {
- if (!$this->singleCustomerTitle->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCustomerTitle->getValidationFailures());
+ if ($this->collAddresss !== null) {
+ foreach ($this->collAddresss as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
}
}
@@ -1802,14 +1820,14 @@ abstract class BaseCustomer extends BaseObject implements Persistent
$keys[23] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAddress) {
- $result['Address'] = $this->aAddress->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->aOrder) {
- $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAddresss) {
+ $result['Addresss'] = $this->collAddresss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->singleCustomerTitle) {
- $result['CustomerTitle'] = $this->singleCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -2094,19 +2112,16 @@ abstract class BaseCustomer extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCustomerTitle();
- if ($relObj) {
- $copyObj->setCustomerTitle($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));
+ }
}
- $relObj = $this->getAddress();
- if ($relObj) {
- $copyObj->setAddress($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getOrder();
- if ($relObj) {
- $copyObj->setOrder($relObj->copy($deepCopy));
+ foreach ($this->getOrders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrder($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -2160,25 +2175,26 @@ abstract class BaseCustomer extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a Address object.
+ * Declares an association between this object and a CustomerTitle object.
*
- * @param Address $v
+ * @param CustomerTitle $v
* @return Customer The current object (for fluent API support)
* @throws PropelException
*/
- public function setAddress(Address $v = null)
+ public function setCustomerTitle(CustomerTitle $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setCustomerTitleId(NULL);
} else {
- $this->setId($v->getCustomerId());
+ $this->setCustomerTitleId($v->getId());
}
- $this->aAddress = $v;
+ $this->aCustomerTitle = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the CustomerTitle object, it will not be re-added.
if ($v !== null) {
- $v->setCustomer($this);
+ $v->addCustomer($this);
}
@@ -2187,70 +2203,26 @@ abstract class BaseCustomer extends BaseObject implements Persistent
/**
- * Get the associated Address object
+ * Get the associated CustomerTitle object
*
* @param PropelPDO $con Optional Connection object.
- * @return Address The associated Address object.
+ * @return CustomerTitle The associated CustomerTitle object.
* @throws PropelException
*/
- public function getAddress(PropelPDO $con = null)
+ public function getCustomerTitle(PropelPDO $con = null)
{
- if ($this->aAddress === null && ($this->id !== null)) {
- $this->aAddress = AddressQuery::create()
- ->filterByCustomer($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAddress->setCustomer($this);
+ if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) {
+ $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_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->aCustomerTitle->addCustomers($this);
+ */
}
- return $this->aAddress;
- }
-
- /**
- * Declares an association between this object and a Order object.
- *
- * @param Order $v
- * @return Customer The current object (for fluent API support)
- * @throws PropelException
- */
- public function setOrder(Order $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getCustomerId());
- }
-
- $this->aOrder = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCustomer($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated Order object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Order The associated Order object.
- * @throws PropelException
- */
- public function getOrder(PropelPDO $con = null)
- {
- if ($this->aOrder === null && ($this->id !== null)) {
- $this->aOrder = OrderQuery::create()
- ->filterByCustomer($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aOrder->setCustomer($this);
- }
-
- return $this->aOrder;
+ return $this->aCustomerTitle;
}
@@ -2264,44 +2236,553 @@ abstract class BaseCustomer extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ if ('Address' == $relationName) {
+ $this->initAddresss();
+ }
+ if ('Order' == $relationName) {
+ $this->initOrders();
+ }
}
/**
- * Gets a single CustomerTitle object, which is related to this object by a one-to-one relationship.
+ * Clears out the collAddresss 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 addAddresss()
+ */
+ public function clearAddresss()
+ {
+ $this->collAddresss = null; // important to set this to null since that means it is uninitialized
+ $this->collAddresssPartial = null;
+ }
+
+ /**
+ * reset is the collAddresss collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAddresss($v = true)
+ {
+ $this->collAddresssPartial = $v;
+ }
+
+ /**
+ * Initializes the collAddresss collection.
+ *
+ * By default this just sets the collAddresss collection to an empty array (like clearcollAddresss());
+ * 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 initAddresss($overrideExisting = true)
+ {
+ if (null !== $this->collAddresss && !$overrideExisting) {
+ return;
+ }
+ $this->collAddresss = new PropelObjectCollection();
+ $this->collAddresss->setModel('Address');
+ }
+
+ /**
+ * Gets an array of Address 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 Customer 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 CustomerTitle
+ * @return PropelObjectCollection|Address[] List of Address objects
* @throws PropelException
*/
- public function getCustomerTitle(PropelPDO $con = null)
+ public function getAddresss($criteria = null, PropelPDO $con = null)
{
+ $partial = $this->collAddresssPartial && !$this->isNew();
+ if (null === $this->collAddresss || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAddresss) {
+ // return empty collection
+ $this->initAddresss();
+ } else {
+ $collAddresss = AddressQuery::create(null, $criteria)
+ ->filterByCustomer($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAddresssPartial && count($collAddresss)) {
+ $this->initAddresss(false);
- if ($this->singleCustomerTitle === null && !$this->isNew()) {
- $this->singleCustomerTitle = CustomerTitleQuery::create()->findPk($this->getPrimaryKey(), $con);
+ foreach($collAddresss as $obj) {
+ if (false == $this->collAddresss->contains($obj)) {
+ $this->collAddresss->append($obj);
+ }
+ }
+
+ $this->collAddresssPartial = true;
+ }
+
+ return $collAddresss;
+ }
+
+ if($partial && $this->collAddresss) {
+ foreach($this->collAddresss as $obj) {
+ if($obj->isNew()) {
+ $collAddresss[] = $obj;
+ }
+ }
+ }
+
+ $this->collAddresss = $collAddresss;
+ $this->collAddresssPartial = false;
+ }
}
- return $this->singleCustomerTitle;
+ return $this->collAddresss;
}
/**
- * Sets a single CustomerTitle object as related to this object by a one-to-one relationship.
+ * Sets a collection of Address 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 CustomerTitle $v CustomerTitle
- * @return Customer The current object (for fluent API support)
+ * @param PropelCollection $addresss A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAddresss(PropelCollection $addresss, PropelPDO $con = null)
+ {
+ $this->addresssScheduledForDeletion = $this->getAddresss(new Criteria(), $con)->diff($addresss);
+
+ foreach ($this->addresssScheduledForDeletion as $addressRemoved) {
+ $addressRemoved->setCustomer(null);
+ }
+
+ $this->collAddresss = null;
+ foreach ($addresss as $address) {
+ $this->addAddress($address);
+ }
+
+ $this->collAddresss = $addresss;
+ $this->collAddresssPartial = false;
+ }
+
+ /**
+ * Returns the number of related Address objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Address objects.
* @throws PropelException
*/
- public function setCustomerTitle(CustomerTitle $v = null)
+ public function countAddresss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleCustomerTitle = $v;
+ $partial = $this->collAddresssPartial && !$this->isNew();
+ if (null === $this->collAddresss || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAddresss) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAddresss());
+ }
+ $query = AddressQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
- // Make sure that that the passed-in CustomerTitle isn't already associated with this object
- if ($v !== null && $v->getCustomer() === null) {
- $v->setCustomer($this);
+ return $query
+ ->filterByCustomer($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAddresss);
+ }
+ }
+
+ /**
+ * Method called to associate a Address object to this object
+ * through the Address foreign key attribute.
+ *
+ * @param Address $l Address
+ * @return Customer The current object (for fluent API support)
+ */
+ public function addAddress(Address $l)
+ {
+ if ($this->collAddresss === null) {
+ $this->initAddresss();
+ $this->collAddresssPartial = true;
+ }
+ if (!$this->collAddresss->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAddress($l);
}
return $this;
}
+ /**
+ * @param Address $address The address object to add.
+ */
+ protected function doAddAddress($address)
+ {
+ $this->collAddresss[]= $address;
+ $address->setCustomer($this);
+ }
+
+ /**
+ * @param Address $address The address object to remove.
+ */
+ public function removeAddress($address)
+ {
+ if ($this->getAddresss()->contains($address)) {
+ $this->collAddresss->remove($this->collAddresss->search($address));
+ if (null === $this->addresssScheduledForDeletion) {
+ $this->addresssScheduledForDeletion = clone $this->collAddresss;
+ $this->addresssScheduledForDeletion->clear();
+ }
+ $this->addresssScheduledForDeletion[]= $address;
+ $address->setCustomer(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Addresss 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 Customer.
+ *
+ * @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|Address[] List of Address objects
+ */
+ public function getAddresssJoinCustomerTitle($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AddressQuery::create(null, $criteria);
+ $query->joinWith('CustomerTitle', $join_behavior);
+
+ return $this->getAddresss($query, $con);
+ }
+
+ /**
+ * Clears out the collOrders 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 addOrders()
+ */
+ public function clearOrders()
+ {
+ $this->collOrders = null; // important to set this to null since that means it is uninitialized
+ $this->collOrdersPartial = null;
+ }
+
+ /**
+ * reset is the collOrders collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialOrders($v = true)
+ {
+ $this->collOrdersPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrders collection.
+ *
+ * By default this just sets the collOrders collection to an empty array (like clearcollOrders());
+ * 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 initOrders($overrideExisting = true)
+ {
+ if (null !== $this->collOrders && !$overrideExisting) {
+ return;
+ }
+ $this->collOrders = new PropelObjectCollection();
+ $this->collOrders->setModel('Order');
+ }
+
+ /**
+ * Gets an array of Order 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 Customer 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|Order[] List of Order objects
+ * @throws PropelException
+ */
+ public function getOrders($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ // return empty collection
+ $this->initOrders();
+ } else {
+ $collOrders = OrderQuery::create(null, $criteria)
+ ->filterByCustomer($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersPartial && count($collOrders)) {
+ $this->initOrders(false);
+
+ foreach($collOrders as $obj) {
+ if (false == $this->collOrders->contains($obj)) {
+ $this->collOrders->append($obj);
+ }
+ }
+
+ $this->collOrdersPartial = true;
+ }
+
+ return $collOrders;
+ }
+
+ if($partial && $this->collOrders) {
+ foreach($this->collOrders as $obj) {
+ if($obj->isNew()) {
+ $collOrders[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrders = $collOrders;
+ $this->collOrdersPartial = false;
+ }
+ }
+
+ return $this->collOrders;
+ }
+
+ /**
+ * Sets a collection of Order 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 $orders A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setOrders(PropelCollection $orders, PropelPDO $con = null)
+ {
+ $this->ordersScheduledForDeletion = $this->getOrders(new Criteria(), $con)->diff($orders);
+
+ foreach ($this->ordersScheduledForDeletion as $orderRemoved) {
+ $orderRemoved->setCustomer(null);
+ }
+
+ $this->collOrders = null;
+ foreach ($orders as $order) {
+ $this->addOrder($order);
+ }
+
+ $this->collOrders = $orders;
+ $this->collOrdersPartial = false;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getOrders());
+ }
+ $query = OrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomer($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collOrders);
+ }
+ }
+
+ /**
+ * Method called to associate a Order object to this object
+ * through the Order foreign key attribute.
+ *
+ * @param Order $l Order
+ * @return Customer The current object (for fluent API support)
+ */
+ public function addOrder(Order $l)
+ {
+ if ($this->collOrders === null) {
+ $this->initOrders();
+ $this->collOrdersPartial = true;
+ }
+ if (!$this->collOrders->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddOrder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Order $order The order object to add.
+ */
+ protected function doAddOrder($order)
+ {
+ $this->collOrders[]= $order;
+ $order->setCustomer($this);
+ }
+
+ /**
+ * @param Order $order The order object to remove.
+ */
+ public function removeOrder($order)
+ {
+ if ($this->getOrders()->contains($order)) {
+ $this->collOrders->remove($this->collOrders->search($order));
+ if (null === $this->ordersScheduledForDeletion) {
+ $this->ordersScheduledForDeletion = clone $this->collOrders;
+ $this->ordersScheduledForDeletion->clear();
+ }
+ $this->ordersScheduledForDeletion[]= $order;
+ $order->setCustomer(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Orders 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 Customer.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('Currency', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Orders 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 Customer.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Orders 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 Customer.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Orders 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 Customer.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderStatus', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -2351,17 +2832,27 @@ abstract class BaseCustomer extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCustomerTitle) {
- $this->singleCustomerTitle->clearAllReferences($deep);
+ if ($this->collAddresss) {
+ foreach ($this->collAddresss as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrders) {
+ foreach ($this->collOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
}
} // if ($deep)
- if ($this->singleCustomerTitle instanceof PropelCollection) {
- $this->singleCustomerTitle->clearIterator();
+ if ($this->collAddresss instanceof PropelCollection) {
+ $this->collAddresss->clearIterator();
}
- $this->singleCustomerTitle = null;
- $this->aAddress = null;
- $this->aOrder = null;
+ $this->collAddresss = null;
+ if ($this->collOrders instanceof PropelCollection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
+ $this->aCustomerTitle = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCustomerPeer.php b/core/lib/Thelia/Model/om/BaseCustomerPeer.php
index 7cb65a650..75448e400 100644
--- a/core/lib/Thelia/Model/om/BaseCustomerPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCustomerPeer.php
@@ -27,7 +27,7 @@ abstract class BaseCustomerPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'customer';
@@ -480,9 +480,12 @@ abstract class BaseCustomerPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CustomerTitlePeer instance pool,
+ // Invalidate objects in AddressPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CustomerTitlePeer::clearInstancePool();
+ AddressPeer::clearInstancePool();
+ // Invalidate objects in OrderPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderPeer::clearInstancePool();
}
/**
@@ -581,7 +584,7 @@ abstract class BaseCustomerPeer
/**
- * Returns the number of rows matching criteria, joining the related Address table
+ * Returns the number of rows matching criteria, joining the related CustomerTitle table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -589,7 +592,7 @@ abstract class BaseCustomerPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinAddress(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinCustomerTitle(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;
@@ -616,7 +619,7 @@ abstract class BaseCustomerPeer
$con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(CustomerPeer::ID, AddressPeer::CUSTOMER_ID, $join_behavior);
+ $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -632,58 +635,7 @@ abstract class BaseCustomerPeer
/**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerPeer::ID, OrderPeer::CUSTOMER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Customer objects pre-filled with their Address objects.
+ * Selects a collection of Customer objects pre-filled with their CustomerTitle objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -691,7 +643,7 @@ abstract class BaseCustomerPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinAddress(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -702,9 +654,9 @@ abstract class BaseCustomerPeer
CustomerPeer::addSelectColumns($criteria);
$startcol = CustomerPeer::NUM_HYDRATE_COLUMNS;
- AddressPeer::addSelectColumns($criteria);
+ CustomerTitlePeer::addSelectColumns($criteria);
- $criteria->addJoin(CustomerPeer::ID, AddressPeer::CUSTOMER_ID, $join_behavior);
+ $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -724,89 +676,20 @@ abstract class BaseCustomerPeer
CustomerPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = AddressPeer::getInstanceFromPool($key2);
+ $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = AddressPeer::getOMClass();
+ $cls = CustomerTitlePeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- AddressPeer::addInstanceToPool($obj2, $key2);
+ CustomerTitlePeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (Customer) to $obj2 (Address)
- // one to one relationship
- $obj1->setAddress($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Customer objects pre-filled with their Order objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Customer objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerPeer::DATABASE_NAME);
- }
-
- CustomerPeer::addSelectColumns($criteria);
- $startcol = CustomerPeer::NUM_HYDRATE_COLUMNS;
- OrderPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CustomerPeer::ID, OrderPeer::CUSTOMER_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CustomerPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Customer) to $obj2 (Order)
- // one to one relationship
- $obj1->setOrder($obj2);
+ // Add the $obj1 (Customer) to $obj2 (CustomerTitle)
+ $obj2->addCustomer($obj1);
} // if joined row was not null
@@ -854,9 +737,7 @@ abstract class BaseCustomerPeer
$con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(CustomerPeer::ID, AddressPeer::CUSTOMER_ID, $join_behavior);
-
- $criteria->addJoin(CustomerPeer::ID, OrderPeer::CUSTOMER_ID, $join_behavior);
+ $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -892,15 +773,10 @@ abstract class BaseCustomerPeer
CustomerPeer::addSelectColumns($criteria);
$startcol2 = CustomerPeer::NUM_HYDRATE_COLUMNS;
- AddressPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AddressPeer::NUM_HYDRATE_COLUMNS;
+ CustomerTitlePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
- OrderPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + OrderPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CustomerPeer::ID, AddressPeer::CUSTOMER_ID, $join_behavior);
-
- $criteria->addJoin(CustomerPeer::ID, OrderPeer::CUSTOMER_ID, $join_behavior);
+ $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -919,292 +795,24 @@ abstract class BaseCustomerPeer
CustomerPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined Address rows
+ // Add objects for joined CustomerTitle rows
- $key2 = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = AddressPeer::getInstanceFromPool($key2);
+ $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = AddressPeer::getOMClass();
+ $cls = CustomerTitlePeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- AddressPeer::addInstanceToPool($obj2, $key2);
+ CustomerTitlePeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (Customer) to the collection in $obj2 (Address)
- $obj1->setAddress($obj2);
+ // Add the $obj1 (Customer) to the collection in $obj2 (CustomerTitle)
+ $obj2->addCustomer($obj1);
} // if joined row not null
- // Add objects for joined Order rows
-
- $key3 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = OrderPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- OrderPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Customer) to the collection in $obj3 (Order)
- $obj1->setOrder($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Address table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAddress(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerPeer::ID, OrderPeer::CUSTOMER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerPeer::ID, AddressPeer::CUSTOMER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Customer objects pre-filled with all related objects except Address.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Customer objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAddress(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerPeer::DATABASE_NAME);
- }
-
- CustomerPeer::addSelectColumns($criteria);
- $startcol2 = CustomerPeer::NUM_HYDRATE_COLUMNS;
-
- OrderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CustomerPeer::ID, OrderPeer::CUSTOMER_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CustomerPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Order rows
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Customer) to the collection in $obj2 (Order)
- $obj1->setOrder($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Customer objects pre-filled with all related objects except Order.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Customer objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerPeer::DATABASE_NAME);
- }
-
- CustomerPeer::addSelectColumns($criteria);
- $startcol2 = CustomerPeer::NUM_HYDRATE_COLUMNS;
-
- AddressPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AddressPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CustomerPeer::ID, AddressPeer::CUSTOMER_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CustomerPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Address rows
-
- $key2 = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AddressPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AddressPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AddressPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Customer) to the collection in $obj2 (Address)
- $obj1->setAddress($obj2);
-
- } // if joined row is not null
-
$results[] = $obj1;
}
$stmt->closeCursor();
@@ -1345,7 +953,6 @@ abstract class BaseCustomerPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- CustomerPeer::doOnDeleteSetNull(new Criteria(CustomerPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CustomerPeer::TABLE_NAME, $con, CustomerPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -1379,14 +986,24 @@ abstract class BaseCustomerPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CustomerPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Customer) { // it's a model object
+ // invalidate the cache for this single object
+ CustomerPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CustomerPeer::DATABASE_NAME);
$criteria->add(CustomerPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CustomerPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -1399,23 +1016,6 @@ abstract class BaseCustomerPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- CustomerPeer::doOnDeleteSetNull($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- CustomerPeer::clearInstancePool();
- } elseif ($values instanceof Customer) { // it's a model object
- CustomerPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- CustomerPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
CustomerPeer::clearRelatedInstancePool();
$con->commit();
@@ -1427,37 +1027,6 @@ abstract class BaseCustomerPeer
}
}
- /**
- * This is a method for emulating ON DELETE SET NULL DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return void
- */
- protected static function doOnDeleteSetNull(Criteria $criteria, PropelPDO $con)
- {
-
- // first find the objects that are implicated by the $criteria
- $objects = CustomerPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
- // set fkey col in related CustomerTitle rows to null
- $selectCriteria = new Criteria(CustomerPeer::DATABASE_NAME);
- $updateValues = new Criteria(CustomerPeer::DATABASE_NAME);
- $selectCriteria->add(CustomerTitlePeer::ID, $obj->getCustomerTitleId());
- $updateValues->add(CustomerTitlePeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- }
- }
-
/**
* Validates all modified columns of given Customer object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseCustomerQuery.php b/core/lib/Thelia/Model/om/BaseCustomerQuery.php
index 1073bf690..39b21ba14 100644
--- a/core/lib/Thelia/Model/om/BaseCustomerQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCustomerQuery.php
@@ -78,6 +78,10 @@ use Thelia\Model\Order;
* @method CustomerQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method CustomerQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
+ * @method CustomerQuery leftJoinCustomerTitle($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitle relation
+ * @method CustomerQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation
+ * @method CustomerQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation
+ *
* @method CustomerQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation
* @method CustomerQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation
* @method CustomerQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation
@@ -86,10 +90,6 @@ use Thelia\Model\Order;
* @method CustomerQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
* @method CustomerQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
*
- * @method CustomerQuery leftJoinCustomerTitle($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitle relation
- * @method CustomerQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation
- * @method CustomerQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation
- *
* @method Customer findOne(PropelPDO $con = null) Return the first Customer matching the query
* @method Customer findOneOrCreate(PropelPDO $con = null) Return the first Customer matching the query, or a new Customer object populated from the query conditions when no match is found
*
@@ -154,7 +154,7 @@ abstract class BaseCustomerQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Customer', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Customer', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -330,10 +330,6 @@ abstract class BaseCustomerQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAddress()
- *
- * @see filterByOrder()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -390,6 +386,8 @@ abstract class BaseCustomerQuery extends ModelCriteria
* $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
*
*
+ * @see filterByCustomerTitle()
+ *
* @param mixed $customerTitleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -1094,10 +1092,86 @@ abstract class BaseCustomerQuery extends ModelCriteria
return $this->addUsingAlias(CustomerPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query by a related CustomerTitle object
+ *
+ * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCustomerTitle($customerTitle, $comparison = null)
+ {
+ if ($customerTitle instanceof CustomerTitle) {
+ return $this
+ ->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
+ } elseif ($customerTitle instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CustomerTitle relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CustomerTitle');
+
+ // 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, 'CustomerTitle');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CustomerTitle relation CustomerTitle 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\CustomerTitleQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCustomerTitle($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
+ }
+
/**
* Filter the query by a related Address object
*
- * @param Address|PropelObjectCollection $address The related object(s) to use as filter
+ * @param Address|PropelObjectCollection $address the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CustomerQuery The current query, for fluid interface
@@ -1109,12 +1183,10 @@ abstract class BaseCustomerQuery extends ModelCriteria
return $this
->addUsingAlias(CustomerPeer::ID, $address->getCustomerId(), $comparison);
} elseif ($address instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CustomerPeer::ID, $address->toKeyValue('PrimaryKey', 'CustomerId'), $comparison);
+ ->useAddressQuery()
+ ->filterByPrimaryKeys($address->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection');
}
@@ -1173,7 +1245,7 @@ abstract class BaseCustomerQuery extends ModelCriteria
/**
* Filter the query by a related Order object
*
- * @param Order|PropelObjectCollection $order The related object(s) to use as filter
+ * @param Order|PropelObjectCollection $order the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CustomerQuery The current query, for fluid interface
@@ -1185,12 +1257,10 @@ abstract class BaseCustomerQuery extends ModelCriteria
return $this
->addUsingAlias(CustomerPeer::ID, $order->getCustomerId(), $comparison);
} elseif ($order instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CustomerPeer::ID, $order->toKeyValue('PrimaryKey', 'CustomerId'), $comparison);
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
}
@@ -1246,80 +1316,6 @@ abstract class BaseCustomerQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
}
- /**
- * Filter the query by a related CustomerTitle object
- *
- * @param CustomerTitle|PropelObjectCollection $customerTitle the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return CustomerQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByCustomerTitle($customerTitle, $comparison = null)
- {
- if ($customerTitle instanceof CustomerTitle) {
- return $this
- ->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
- } elseif ($customerTitle instanceof PropelObjectCollection) {
- return $this
- ->useCustomerTitleQuery()
- ->filterByPrimaryKeys($customerTitle->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the CustomerTitle relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return CustomerQuery The current query, for fluid interface
- */
- public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('CustomerTitle');
-
- // 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, 'CustomerTitle');
- }
-
- return $this;
- }
-
- /**
- * Use the CustomerTitle relation CustomerTitle 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\CustomerTitleQuery A secondary query class using the current class as primary query
- */
- public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinCustomerTitle($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
- }
-
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitle.php b/core/lib/Thelia/Model/om/BaseCustomerTitle.php
index 075b2128b..6a91ebd96 100644
--- a/core/lib/Thelia/Model/om/BaseCustomerTitle.php
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitle.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Address;
use Thelia\Model\AddressQuery;
@@ -83,19 +85,22 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Address
+ * @var PropelObjectCollection|Address[] Collection to store aggregation of Address objects.
*/
- protected $aAddress;
+ protected $collAddresss;
+ protected $collAddresssPartial;
/**
- * @var Customer
+ * @var PropelObjectCollection|Customer[] Collection to store aggregation of Customer objects.
*/
- protected $aCustomer;
+ protected $collCustomers;
+ protected $collCustomersPartial;
/**
- * @var CustomerTitleDesc
+ * @var PropelObjectCollection|CustomerTitleDesc[] Collection to store aggregation of CustomerTitleDesc objects.
*/
- protected $aCustomerTitleDesc;
+ protected $collCustomerTitleDescs;
+ protected $collCustomerTitleDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -111,6 +116,24 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $addresssScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $customersScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $customerTitleDescsScheduledForDeletion = null;
+
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
@@ -253,18 +276,6 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
$this->modifiedColumns[] = CustomerTitlePeer::ID;
}
- if ($this->aAddress !== null && $this->aAddress->getCustomerTitleId() !== $v) {
- $this->aAddress = null;
- }
-
- if ($this->aCustomer !== null && $this->aCustomer->getCustomerTitleId() !== $v) {
- $this->aCustomer = null;
- }
-
- if ($this->aCustomerTitleDesc !== null && $this->aCustomerTitleDesc->getCustomerTitleId() !== $v) {
- $this->aCustomerTitleDesc = null;
- }
-
return $this;
} // setId()
@@ -429,15 +440,6 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAddress !== null && $this->id !== $this->aAddress->getCustomerTitleId()) {
- $this->aAddress = null;
- }
- if ($this->aCustomer !== null && $this->id !== $this->aCustomer->getCustomerTitleId()) {
- $this->aCustomer = null;
- }
- if ($this->aCustomerTitleDesc !== null && $this->id !== $this->aCustomerTitleDesc->getCustomerTitleId()) {
- $this->aCustomerTitleDesc = null;
- }
} // ensureConsistency
/**
@@ -477,9 +479,12 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAddress = null;
- $this->aCustomer = null;
- $this->aCustomerTitleDesc = null;
+ $this->collAddresss = null;
+
+ $this->collCustomers = null;
+
+ $this->collCustomerTitleDescs = null;
+
} // if (deep)
}
@@ -593,32 +598,6 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAddress !== null) {
- if ($this->aAddress->isModified() || $this->aAddress->isNew()) {
- $affectedRows += $this->aAddress->save($con);
- }
- $this->setAddress($this->aAddress);
- }
-
- if ($this->aCustomer !== null) {
- if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) {
- $affectedRows += $this->aCustomer->save($con);
- }
- $this->setCustomer($this->aCustomer);
- }
-
- if ($this->aCustomerTitleDesc !== null) {
- if ($this->aCustomerTitleDesc->isModified() || $this->aCustomerTitleDesc->isNew()) {
- $affectedRows += $this->aCustomerTitleDesc->save($con);
- }
- $this->setCustomerTitleDesc($this->aCustomerTitleDesc);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -630,6 +609,59 @@ 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) {
+ // need to save related object because we set the relation to null
+ $customer->save($con);
+ }
+ $this->customersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCustomers !== null) {
+ foreach ($this->collCustomers as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->customerTitleDescsScheduledForDeletion !== null) {
+ if (!$this->customerTitleDescsScheduledForDeletion->isEmpty()) {
+ CustomerTitleDescQuery::create()
+ ->filterByPrimaryKeys($this->customerTitleDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->customerTitleDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCustomerTitleDescs !== null) {
+ foreach ($this->collCustomerTitleDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -791,35 +823,35 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAddress !== null) {
- if (!$this->aAddress->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAddress->getValidationFailures());
- }
- }
-
- if ($this->aCustomer !== null) {
- if (!$this->aCustomer->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aCustomer->getValidationFailures());
- }
- }
-
- if ($this->aCustomerTitleDesc !== null) {
- if (!$this->aCustomerTitleDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aCustomerTitleDesc->getValidationFailures());
- }
- }
-
-
if (($retval = CustomerTitlePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collAddresss !== null) {
+ foreach ($this->collAddresss as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collCustomers !== null) {
+ foreach ($this->collCustomers as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collCustomerTitleDescs !== null) {
+ foreach ($this->collCustomerTitleDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -906,14 +938,14 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAddress) {
- $result['Address'] = $this->aAddress->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAddresss) {
+ $result['Addresss'] = $this->collAddresss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aCustomer) {
- $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collCustomers) {
+ $result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aCustomerTitleDesc) {
- $result['CustomerTitleDesc'] = $this->aCustomerTitleDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collCustomerTitleDescs) {
+ $result['CustomerTitleDescs'] = $this->collCustomerTitleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1084,19 +1116,22 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAddress();
- if ($relObj) {
- $copyObj->setAddress($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));
+ }
}
- $relObj = $this->getCustomer();
- if ($relObj) {
- $copyObj->setCustomer($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));
+ }
}
- $relObj = $this->getCustomerTitleDesc();
- if ($relObj) {
- $copyObj->setCustomerTitleDesc($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));
+ }
}
//unflag object copy
@@ -1149,145 +1184,672 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a Address object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param Address $v
- * @return CustomerTitle The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Address' == $relationName) {
+ $this->initAddresss();
+ }
+ if ('Customer' == $relationName) {
+ $this->initCustomers();
+ }
+ if ('CustomerTitleDesc' == $relationName) {
+ $this->initCustomerTitleDescs();
+ }
+ }
+
+ /**
+ * Clears out the collAddresss 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 addAddresss()
+ */
+ public function clearAddresss()
+ {
+ $this->collAddresss = null; // important to set this to null since that means it is uninitialized
+ $this->collAddresssPartial = null;
+ }
+
+ /**
+ * reset is the collAddresss collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAddresss($v = true)
+ {
+ $this->collAddresssPartial = $v;
+ }
+
+ /**
+ * Initializes the collAddresss collection.
+ *
+ * By default this just sets the collAddresss collection to an empty array (like clearcollAddresss());
+ * 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 initAddresss($overrideExisting = true)
+ {
+ if (null !== $this->collAddresss && !$overrideExisting) {
+ return;
+ }
+ $this->collAddresss = new PropelObjectCollection();
+ $this->collAddresss->setModel('Address');
+ }
+
+ /**
+ * Gets an array of Address 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|Address[] List of Address objects
* @throws PropelException
*/
- public function setAddress(Address $v = null)
+ public function getAddresss($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collAddresssPartial && !$this->isNew();
+ if (null === $this->collAddresss || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAddresss) {
+ // return empty collection
+ $this->initAddresss();
+ } else {
+ $collAddresss = AddressQuery::create(null, $criteria)
+ ->filterByCustomerTitle($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAddresssPartial && count($collAddresss)) {
+ $this->initAddresss(false);
+
+ foreach($collAddresss as $obj) {
+ if (false == $this->collAddresss->contains($obj)) {
+ $this->collAddresss->append($obj);
+ }
+ }
+
+ $this->collAddresssPartial = true;
+ }
+
+ return $collAddresss;
+ }
+
+ if($partial && $this->collAddresss) {
+ foreach($this->collAddresss as $obj) {
+ if($obj->isNew()) {
+ $collAddresss[] = $obj;
+ }
+ }
+ }
+
+ $this->collAddresss = $collAddresss;
+ $this->collAddresssPartial = false;
+ }
+ }
+
+ return $this->collAddresss;
+ }
+
+ /**
+ * Sets a collection of Address 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 $addresss A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAddresss(PropelCollection $addresss, PropelPDO $con = null)
+ {
+ $this->addresssScheduledForDeletion = $this->getAddresss(new Criteria(), $con)->diff($addresss);
+
+ foreach ($this->addresssScheduledForDeletion as $addressRemoved) {
+ $addressRemoved->setCustomerTitle(null);
+ }
+
+ $this->collAddresss = null;
+ foreach ($addresss as $address) {
+ $this->addAddress($address);
+ }
+
+ $this->collAddresss = $addresss;
+ $this->collAddresssPartial = false;
+ }
+
+ /**
+ * Returns the number of related Address objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Address objects.
+ * @throws PropelException
+ */
+ public function countAddresss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAddresssPartial && !$this->isNew();
+ if (null === $this->collAddresss || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAddresss) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAddresss());
+ }
+ $query = AddressQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomerTitle($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCustomerTitleId());
+ return count($this->collAddresss);
}
+ }
- $this->aAddress = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCustomerTitle($this);
+ /**
+ * Method called to associate a Address object to this object
+ * through the Address foreign key attribute.
+ *
+ * @param Address $l Address
+ * @return CustomerTitle The current object (for fluent API support)
+ */
+ public function addAddress(Address $l)
+ {
+ if ($this->collAddresss === null) {
+ $this->initAddresss();
+ $this->collAddresssPartial = true;
+ }
+ if (!$this->collAddresss->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAddress($l);
}
-
return $this;
}
-
/**
- * Get the associated Address object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Address The associated Address object.
- * @throws PropelException
+ * @param Address $address The address object to add.
*/
- public function getAddress(PropelPDO $con = null)
+ protected function doAddAddress($address)
{
- if ($this->aAddress === null && ($this->id !== null)) {
- $this->aAddress = AddressQuery::create()
- ->filterByCustomerTitle($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAddress->setCustomerTitle($this);
- }
-
- return $this->aAddress;
+ $this->collAddresss[]= $address;
+ $address->setCustomerTitle($this);
}
/**
- * Declares an association between this object and a Customer object.
+ * @param Address $address The address object to remove.
+ */
+ public function removeAddress($address)
+ {
+ if ($this->getAddresss()->contains($address)) {
+ $this->collAddresss->remove($this->collAddresss->search($address));
+ if (null === $this->addresssScheduledForDeletion) {
+ $this->addresssScheduledForDeletion = clone $this->collAddresss;
+ $this->addresssScheduledForDeletion->clear();
+ }
+ $this->addresssScheduledForDeletion[]= $address;
+ $address->setCustomerTitle(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CustomerTitle is new, it will return
+ * an empty collection; or if this CustomerTitle has previously
+ * been saved, it will retrieve related Addresss from storage.
*
- * @param Customer $v
- * @return CustomerTitle The current object (for fluent API support)
+ * 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 CustomerTitle.
+ *
+ * @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|Address[] List of Address objects
+ */
+ public function getAddresssJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AddressQuery::create(null, $criteria);
+ $query->joinWith('Customer', $join_behavior);
+
+ 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 setCustomer(Customer $v = null)
+ public function getCustomers($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getCustomerTitleId());
+ return count($this->collCustomers);
}
+ }
- $this->aCustomer = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCustomerTitle($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated Customer object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Customer The associated Customer object.
- * @throws PropelException
+ * @param Customer $customer The customer object to add.
*/
- public function getCustomer(PropelPDO $con = null)
+ protected function doAddCustomer($customer)
{
- if ($this->aCustomer === null && ($this->id !== null)) {
- $this->aCustomer = CustomerQuery::create()
- ->filterByCustomerTitle($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aCustomer->setCustomerTitle($this);
- }
-
- return $this->aCustomer;
+ $this->collCustomers[]= $customer;
+ $customer->setCustomerTitle($this);
}
/**
- * Declares an association between this object and a CustomerTitleDesc object.
+ * @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
*
- * @param CustomerTitleDesc $v
- * @return CustomerTitle The current object (for fluent API support)
+ * 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 addCustomerTitleDescs()
+ */
+ public function clearCustomerTitleDescs()
+ {
+ $this->collCustomerTitleDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collCustomerTitleDescsPartial = null;
+ }
+
+ /**
+ * reset is the collCustomerTitleDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialCustomerTitleDescs($v = true)
+ {
+ $this->collCustomerTitleDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCustomerTitleDescs collection.
+ *
+ * By default this just sets the collCustomerTitleDescs collection to an empty array (like clearcollCustomerTitleDescs());
+ * 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 initCustomerTitleDescs($overrideExisting = true)
+ {
+ if (null !== $this->collCustomerTitleDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collCustomerTitleDescs = new PropelObjectCollection();
+ $this->collCustomerTitleDescs->setModel('CustomerTitleDesc');
+ }
+
+ /**
+ * Gets an array of CustomerTitleDesc 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|CustomerTitleDesc[] List of CustomerTitleDesc objects
* @throws PropelException
*/
- public function setCustomerTitleDesc(CustomerTitleDesc $v = null)
+ public function getCustomerTitleDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collCustomerTitleDescsPartial && !$this->isNew();
+ if (null === $this->collCustomerTitleDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCustomerTitleDescs) {
+ // return empty collection
+ $this->initCustomerTitleDescs();
+ } else {
+ $collCustomerTitleDescs = CustomerTitleDescQuery::create(null, $criteria)
+ ->filterByCustomerTitle($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCustomerTitleDescsPartial && count($collCustomerTitleDescs)) {
+ $this->initCustomerTitleDescs(false);
+
+ foreach($collCustomerTitleDescs as $obj) {
+ if (false == $this->collCustomerTitleDescs->contains($obj)) {
+ $this->collCustomerTitleDescs->append($obj);
+ }
+ }
+
+ $this->collCustomerTitleDescsPartial = true;
+ }
+
+ return $collCustomerTitleDescs;
+ }
+
+ if($partial && $this->collCustomerTitleDescs) {
+ foreach($this->collCustomerTitleDescs as $obj) {
+ if($obj->isNew()) {
+ $collCustomerTitleDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collCustomerTitleDescs = $collCustomerTitleDescs;
+ $this->collCustomerTitleDescsPartial = false;
+ }
+ }
+
+ return $this->collCustomerTitleDescs;
+ }
+
+ /**
+ * Sets a collection of CustomerTitleDesc 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 $customerTitleDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setCustomerTitleDescs(PropelCollection $customerTitleDescs, PropelPDO $con = null)
+ {
+ $this->customerTitleDescsScheduledForDeletion = $this->getCustomerTitleDescs(new Criteria(), $con)->diff($customerTitleDescs);
+
+ foreach ($this->customerTitleDescsScheduledForDeletion as $customerTitleDescRemoved) {
+ $customerTitleDescRemoved->setCustomerTitle(null);
+ }
+
+ $this->collCustomerTitleDescs = null;
+ foreach ($customerTitleDescs as $customerTitleDesc) {
+ $this->addCustomerTitleDesc($customerTitleDesc);
+ }
+
+ $this->collCustomerTitleDescs = $customerTitleDescs;
+ $this->collCustomerTitleDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related CustomerTitleDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CustomerTitleDesc objects.
+ * @throws PropelException
+ */
+ public function countCustomerTitleDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCustomerTitleDescsPartial && !$this->isNew();
+ if (null === $this->collCustomerTitleDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCustomerTitleDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getCustomerTitleDescs());
+ }
+ $query = CustomerTitleDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomerTitle($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getCustomerTitleId());
+ return count($this->collCustomerTitleDescs);
}
+ }
- $this->aCustomerTitleDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setCustomerTitle($this);
+ /**
+ * Method called to associate a CustomerTitleDesc object to this object
+ * through the CustomerTitleDesc foreign key attribute.
+ *
+ * @param CustomerTitleDesc $l CustomerTitleDesc
+ * @return CustomerTitle The current object (for fluent API support)
+ */
+ public function addCustomerTitleDesc(CustomerTitleDesc $l)
+ {
+ if ($this->collCustomerTitleDescs === null) {
+ $this->initCustomerTitleDescs();
+ $this->collCustomerTitleDescsPartial = true;
+ }
+ if (!$this->collCustomerTitleDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddCustomerTitleDesc($l);
}
-
return $this;
}
+ /**
+ * @param CustomerTitleDesc $customerTitleDesc The customerTitleDesc object to add.
+ */
+ protected function doAddCustomerTitleDesc($customerTitleDesc)
+ {
+ $this->collCustomerTitleDescs[]= $customerTitleDesc;
+ $customerTitleDesc->setCustomerTitle($this);
+ }
/**
- * Get the associated CustomerTitleDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return CustomerTitleDesc The associated CustomerTitleDesc object.
- * @throws PropelException
+ * @param CustomerTitleDesc $customerTitleDesc The customerTitleDesc object to remove.
*/
- public function getCustomerTitleDesc(PropelPDO $con = null)
+ public function removeCustomerTitleDesc($customerTitleDesc)
{
- if ($this->aCustomerTitleDesc === null && ($this->id !== null)) {
- $this->aCustomerTitleDesc = CustomerTitleDescQuery::create()
- ->filterByCustomerTitle($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aCustomerTitleDesc->setCustomerTitle($this);
+ if ($this->getCustomerTitleDescs()->contains($customerTitleDesc)) {
+ $this->collCustomerTitleDescs->remove($this->collCustomerTitleDescs->search($customerTitleDesc));
+ if (null === $this->customerTitleDescsScheduledForDeletion) {
+ $this->customerTitleDescsScheduledForDeletion = clone $this->collCustomerTitleDescs;
+ $this->customerTitleDescsScheduledForDeletion->clear();
+ }
+ $this->customerTitleDescsScheduledForDeletion[]= $customerTitleDesc;
+ $customerTitleDesc->setCustomerTitle(null);
}
-
- return $this->aCustomerTitleDesc;
}
/**
@@ -1321,11 +1883,35 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collAddresss) {
+ foreach ($this->collAddresss as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCustomers) {
+ foreach ($this->collCustomers as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCustomerTitleDescs) {
+ foreach ($this->collCustomerTitleDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aAddress = null;
- $this->aCustomer = null;
- $this->aCustomerTitleDesc = null;
+ if ($this->collAddresss instanceof PropelCollection) {
+ $this->collAddresss->clearIterator();
+ }
+ $this->collAddresss = null;
+ if ($this->collCustomers instanceof PropelCollection) {
+ $this->collCustomers->clearIterator();
+ }
+ $this->collCustomers = null;
+ if ($this->collCustomerTitleDescs instanceof PropelCollection) {
+ $this->collCustomerTitleDescs->clearIterator();
+ }
+ $this->collCustomerTitleDescs = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php b/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php
index 8efe8f34a..e73e04c23 100644
--- a/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\CustomerTitle;
use Thelia\Model\CustomerTitleDesc;
@@ -92,9 +90,9 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var CustomerTitle one-to-one related CustomerTitle object
+ * @var CustomerTitle
*/
- protected $singleCustomerTitle;
+ protected $aCustomerTitle;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -110,12 +108,6 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $customerTitlesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -278,6 +270,10 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = CustomerTitleDescPeer::CUSTOMER_TITLE_ID;
}
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
return $this;
} // setCustomerTitleId()
@@ -461,6 +457,9 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
+ }
} // ensureConsistency
/**
@@ -500,8 +499,7 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCustomerTitle = null;
-
+ $this->aCustomerTitle = null;
} // if (deep)
}
@@ -615,6 +613,18 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCustomerTitle !== null) {
+ if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
+ $affectedRows += $this->aCustomerTitle->save($con);
+ }
+ $this->setCustomerTitle($this->aCustomerTitle);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -626,21 +636,6 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->customerTitlesScheduledForDeletion !== null) {
- if (!$this->customerTitlesScheduledForDeletion->isEmpty()) {
- CustomerTitleQuery::create()
- ->filterByPrimaryKeys($this->customerTitlesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->customerTitlesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCustomerTitle !== null) {
- if (!$this->singleCustomerTitle->isDeleted()) {
- $affectedRows += $this->singleCustomerTitle->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -814,17 +809,23 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCustomerTitle !== null) {
+ if (!$this->aCustomerTitle->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCustomerTitle->getValidationFailures());
+ }
+ }
+
+
if (($retval = CustomerTitleDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCustomerTitle !== null) {
- if (!$this->singleCustomerTitle->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCustomerTitle->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -919,8 +920,8 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCustomerTitle) {
- $result['CustomerTitle'] = $this->singleCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1103,11 +1104,6 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCustomerTitle();
- if ($relObj) {
- $copyObj->setCustomerTitle($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1158,55 +1154,57 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a CustomerTitle object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single CustomerTitle object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return CustomerTitle
- * @throws PropelException
- */
- public function getCustomerTitle(PropelPDO $con = null)
- {
-
- if ($this->singleCustomerTitle === null && !$this->isNew()) {
- $this->singleCustomerTitle = CustomerTitleQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCustomerTitle;
- }
-
- /**
- * Sets a single CustomerTitle object as related to this object by a one-to-one relationship.
- *
- * @param CustomerTitle $v CustomerTitle
+ * @param CustomerTitle $v
* @return CustomerTitleDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setCustomerTitle(CustomerTitle $v = null)
{
- $this->singleCustomerTitle = $v;
-
- // Make sure that that the passed-in CustomerTitle isn't already associated with this object
- if ($v !== null && $v->getCustomerTitleDesc() === null) {
- $v->setCustomerTitleDesc($this);
+ if ($v === null) {
+ $this->setCustomerTitleId(NULL);
+ } else {
+ $this->setCustomerTitleId($v->getId());
}
+ $this->aCustomerTitle = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the CustomerTitle object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCustomerTitleDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated CustomerTitle object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return CustomerTitle The associated CustomerTitle object.
+ * @throws PropelException
+ */
+ public function getCustomerTitle(PropelPDO $con = null)
+ {
+ if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) {
+ $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_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->aCustomerTitle->addCustomerTitleDescs($this);
+ */
+ }
+
+ return $this->aCustomerTitle;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1239,15 +1237,9 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCustomerTitle) {
- $this->singleCustomerTitle->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCustomerTitle instanceof PropelCollection) {
- $this->singleCustomerTitle->clearIterator();
- }
- $this->singleCustomerTitle = null;
+ $this->aCustomerTitle = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleDescPeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitleDescPeer.php
index 8b77a4828..0f5f901aa 100644
--- a/core/lib/Thelia/Model/om/BaseCustomerTitleDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitleDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseCustomerTitleDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'customer_title_desc';
@@ -393,9 +393,6 @@ abstract class BaseCustomerTitleDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CustomerTitlePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CustomerTitlePeer::clearInstancePool();
}
/**
@@ -492,6 +489,244 @@ abstract class BaseCustomerTitleDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related CustomerTitle table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCustomerTitle(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CustomerTitleDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CustomerTitleDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of CustomerTitleDesc objects pre-filled with their CustomerTitle objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CustomerTitleDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME);
+ }
+
+ CustomerTitleDescPeer::addSelectColumns($criteria);
+ $startcol = CustomerTitleDescPeer::NUM_HYDRATE_COLUMNS;
+ CustomerTitlePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CustomerTitleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CustomerTitleDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = CustomerTitleDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CustomerTitleDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CustomerTitlePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CustomerTitlePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (CustomerTitleDesc) to $obj2 (CustomerTitle)
+ $obj2->addCustomerTitleDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CustomerTitleDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CustomerTitleDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of CustomerTitleDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CustomerTitleDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME);
+ }
+
+ CustomerTitleDescPeer::addSelectColumns($criteria);
+ $startcol2 = CustomerTitleDescPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerTitlePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CustomerTitleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CustomerTitleDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = CustomerTitleDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CustomerTitleDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined CustomerTitle rows
+
+ $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CustomerTitlePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CustomerTitlePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (CustomerTitleDesc) to the collection in $obj2 (CustomerTitle)
+ $obj2->addCustomerTitleDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -625,7 +860,6 @@ abstract class BaseCustomerTitleDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += CustomerTitleDescPeer::doOnDeleteCascade(new Criteria(CustomerTitleDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CustomerTitleDescPeer::TABLE_NAME, $con, CustomerTitleDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -659,14 +893,24 @@ abstract class BaseCustomerTitleDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CustomerTitleDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CustomerTitleDesc) { // it's a model object
+ // invalidate the cache for this single object
+ CustomerTitleDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CustomerTitleDescPeer::DATABASE_NAME);
$criteria->add(CustomerTitleDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CustomerTitleDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -679,23 +923,6 @@ abstract class BaseCustomerTitleDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += CustomerTitleDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- CustomerTitleDescPeer::clearInstancePool();
- } elseif ($values instanceof CustomerTitleDesc) { // it's a model object
- CustomerTitleDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- CustomerTitleDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
CustomerTitleDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -707,39 +934,6 @@ abstract class BaseCustomerTitleDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = CustomerTitleDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related CustomerTitle objects
- $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME);
-
- $criteria->add(CustomerTitlePeer::ID, $obj->getCustomerTitleId());
- $affectedRows += CustomerTitlePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given CustomerTitleDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php
index 010fe70a5..ff7c9fbec 100644
--- a/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php
@@ -76,7 +76,7 @@ abstract class BaseCustomerTitleDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\CustomerTitleDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\CustomerTitleDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -279,6 +279,8 @@ abstract class BaseCustomerTitleDescQuery extends ModelCriteria
* $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
*
*
+ * @see filterByCustomerTitle()
+ *
* @param mixed $customerTitleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -486,7 +488,7 @@ abstract class BaseCustomerTitleDescQuery extends ModelCriteria
/**
* Filter the query by a related CustomerTitle object
*
- * @param CustomerTitle|PropelObjectCollection $customerTitle the related object to use as filter
+ * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CustomerTitleDescQuery The current query, for fluid interface
@@ -498,10 +500,12 @@ abstract class BaseCustomerTitleDescQuery extends ModelCriteria
return $this
->addUsingAlias(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
} elseif ($customerTitle instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCustomerTitleQuery()
- ->filterByPrimaryKeys($customerTitle->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php
index 8af0eb9f0..ebe4d868d 100644
--- a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php
@@ -9,7 +9,6 @@ use \PDOStatement;
use \Propel;
use \PropelException;
use \PropelPDO;
-use Thelia\Model\AddressPeer;
use Thelia\Model\CustomerPeer;
use Thelia\Model\CustomerTitle;
use Thelia\Model\CustomerTitleDescPeer;
@@ -27,7 +26,7 @@ abstract class BaseCustomerTitlePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'customer_title';
@@ -385,6 +384,12 @@ abstract class BaseCustomerTitlePeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in CustomerPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CustomerPeer::clearInstancePool();
+ // Invalidate objects in CustomerTitleDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CustomerTitleDescPeer::clearInstancePool();
}
/**
@@ -481,986 +486,6 @@ abstract class BaseCustomerTitlePeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related Address table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAddress(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerTitlePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerTitlePeer::ID, AddressPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Customer table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinCustomer(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerTitlePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related CustomerTitleDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinCustomerTitleDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerTitlePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of CustomerTitle objects pre-filled with their Address objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of CustomerTitle objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAddress(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
- }
-
- CustomerTitlePeer::addSelectColumns($criteria);
- $startcol = CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
- AddressPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CustomerTitlePeer::ID, AddressPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerTitlePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CustomerTitlePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerTitlePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AddressPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AddressPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AddressPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (CustomerTitle) to $obj2 (Address)
- // one to one relationship
- $obj1->setAddress($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of CustomerTitle objects pre-filled with their Customer objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of CustomerTitle objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
- }
-
- CustomerTitlePeer::addSelectColumns($criteria);
- $startcol = CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
- CustomerPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerTitlePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CustomerTitlePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerTitlePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = CustomerPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CustomerPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- CustomerPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (CustomerTitle) to $obj2 (Customer)
- // one to one relationship
- $obj1->setCustomer($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of CustomerTitle objects pre-filled with their CustomerTitleDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of CustomerTitle objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinCustomerTitleDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
- }
-
- CustomerTitlePeer::addSelectColumns($criteria);
- $startcol = CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
- CustomerTitleDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerTitlePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = CustomerTitlePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerTitlePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = CustomerTitleDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = CustomerTitleDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CustomerTitleDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- CustomerTitleDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (CustomerTitle) to $obj2 (CustomerTitleDesc)
- // one to one relationship
- $obj1->setCustomerTitleDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerTitlePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerTitlePeer::ID, AddressPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of CustomerTitle objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of CustomerTitle objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
- }
-
- CustomerTitlePeer::addSelectColumns($criteria);
- $startcol2 = CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
-
- AddressPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AddressPeer::NUM_HYDRATE_COLUMNS;
-
- CustomerPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
-
- CustomerTitleDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + CustomerTitleDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CustomerTitlePeer::ID, AddressPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerTitlePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CustomerTitlePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerTitlePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Address rows
-
- $key2 = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AddressPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AddressPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AddressPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj2 (Address)
- $obj1->setAddress($obj2);
- } // if joined row not null
-
- // Add objects for joined Customer rows
-
- $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CustomerPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CustomerPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CustomerPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj3 (Customer)
- $obj1->setCustomer($obj3);
- } // if joined row not null
-
- // Add objects for joined CustomerTitleDesc rows
-
- $key4 = CustomerTitleDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = CustomerTitleDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = CustomerTitleDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- CustomerTitleDescPeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj4 (CustomerTitleDesc)
- $obj1->setCustomerTitleDesc($obj4);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Address table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAddress(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerTitlePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Customer table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptCustomer(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerTitlePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerTitlePeer::ID, AddressPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related CustomerTitleDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptCustomerTitleDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- CustomerTitlePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(CustomerTitlePeer::ID, AddressPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of CustomerTitle objects pre-filled with all related objects except Address.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of CustomerTitle objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAddress(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
- }
-
- CustomerTitlePeer::addSelectColumns($criteria);
- $startcol2 = CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
-
- CustomerPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS;
-
- CustomerTitleDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CustomerTitleDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerTitlePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CustomerTitlePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerTitlePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Customer rows
-
- $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = CustomerPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = CustomerPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- CustomerPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj2 (Customer)
- $obj1->setCustomer($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined CustomerTitleDesc rows
-
- $key3 = CustomerTitleDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CustomerTitleDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CustomerTitleDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CustomerTitleDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj3 (CustomerTitleDesc)
- $obj1->setCustomerTitleDesc($obj3);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of CustomerTitle objects pre-filled with all related objects except Customer.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of CustomerTitle objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
- }
-
- CustomerTitlePeer::addSelectColumns($criteria);
- $startcol2 = CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
-
- AddressPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AddressPeer::NUM_HYDRATE_COLUMNS;
-
- CustomerTitleDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CustomerTitleDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CustomerTitlePeer::ID, AddressPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerTitlePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CustomerTitlePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerTitlePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Address rows
-
- $key2 = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AddressPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AddressPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AddressPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj2 (Address)
- $obj1->setAddress($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined CustomerTitleDesc rows
-
- $key3 = CustomerTitleDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CustomerTitleDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CustomerTitleDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CustomerTitleDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj3 (CustomerTitleDesc)
- $obj1->setCustomerTitleDesc($obj3);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of CustomerTitle objects pre-filled with all related objects except CustomerTitleDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of CustomerTitle objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptCustomerTitleDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
- }
-
- CustomerTitlePeer::addSelectColumns($criteria);
- $startcol2 = CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
-
- AddressPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AddressPeer::NUM_HYDRATE_COLUMNS;
-
- CustomerPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(CustomerTitlePeer::ID, AddressPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
- $criteria->addJoin(CustomerTitlePeer::ID, CustomerPeer::CUSTOMER_TITLE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = CustomerTitlePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = CustomerTitlePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- CustomerTitlePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Address rows
-
- $key2 = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AddressPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AddressPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AddressPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj2 (Address)
- $obj1->setAddress($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Customer rows
-
- $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = CustomerPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = CustomerPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- CustomerPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (CustomerTitle) to the collection in $obj3 (Customer)
- $obj1->setCustomer($obj3);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php
index c63ca2c66..0e0ac3100 100644
--- a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php
@@ -78,7 +78,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\CustomerTitle', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\CustomerTitle', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -254,12 +254,6 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAddress()
- *
- * @see filterByCustomer()
- *
- * @see filterByCustomerTitleDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -436,7 +430,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
/**
* Filter the query by a related Address object
*
- * @param Address|PropelObjectCollection $address The related object(s) to use as filter
+ * @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
@@ -448,12 +442,10 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
return $this
->addUsingAlias(CustomerTitlePeer::ID, $address->getCustomerTitleId(), $comparison);
} elseif ($address instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CustomerTitlePeer::ID, $address->toKeyValue('PrimaryKey', 'CustomerTitleId'), $comparison);
+ ->useAddressQuery()
+ ->filterByPrimaryKeys($address->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection');
}
@@ -467,7 +459,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
*
* @return CustomerTitleQuery The current query, for fluid interface
*/
- public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Address');
@@ -502,7 +494,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
*
* @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query
*/
- public function useAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinAddress($relationAlias, $joinType)
@@ -512,7 +504,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
/**
* Filter the query by a related Customer object
*
- * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter
+ * @param Customer|PropelObjectCollection $customer the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CustomerTitleQuery The current query, for fluid interface
@@ -524,12 +516,10 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
return $this
->addUsingAlias(CustomerTitlePeer::ID, $customer->getCustomerTitleId(), $comparison);
} elseif ($customer instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CustomerTitlePeer::ID, $customer->toKeyValue('PrimaryKey', 'CustomerTitleId'), $comparison);
+ ->useCustomerQuery()
+ ->filterByPrimaryKeys($customer->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
}
@@ -543,7 +533,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
*
* @return CustomerTitleQuery The current query, for fluid interface
*/
- public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Customer');
@@ -578,7 +568,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
*
* @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query
*/
- public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useCustomerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinCustomer($relationAlias, $joinType)
@@ -588,7 +578,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
/**
* Filter the query by a related CustomerTitleDesc object
*
- * @param CustomerTitleDesc|PropelObjectCollection $customerTitleDesc The related object(s) to use as filter
+ * @param CustomerTitleDesc|PropelObjectCollection $customerTitleDesc 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
@@ -600,12 +590,10 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria
return $this
->addUsingAlias(CustomerTitlePeer::ID, $customerTitleDesc->getCustomerTitleId(), $comparison);
} elseif ($customerTitleDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(CustomerTitlePeer::ID, $customerTitleDesc->toKeyValue('PrimaryKey', 'CustomerTitleId'), $comparison);
+ ->useCustomerTitleDescQuery()
+ ->filterByPrimaryKeys($customerTitleDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByCustomerTitleDesc() only accepts arguments of type CustomerTitleDesc or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseDelivzone.php b/core/lib/Thelia/Model/om/BaseDelivzone.php
index a3120badf..a1e31aa18 100644
--- a/core/lib/Thelia/Model/om/BaseDelivzone.php
+++ b/core/lib/Thelia/Model/om/BaseDelivzone.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Area;
use Thelia\Model\AreaQuery;
@@ -80,9 +78,9 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Area one-to-one related Area object
+ * @var Area
*/
- protected $singleArea;
+ protected $aArea;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -98,12 +96,6 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $areasScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -246,6 +238,10 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
$this->modifiedColumns[] = DelivzonePeer::AREA_ID;
}
+ if ($this->aArea !== null && $this->aArea->getId() !== $v) {
+ $this->aArea = null;
+ }
+
return $this;
} // setAreaId()
@@ -385,6 +381,9 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) {
+ $this->aArea = null;
+ }
} // ensureConsistency
/**
@@ -424,8 +423,7 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleArea = null;
-
+ $this->aArea = null;
} // if (deep)
}
@@ -539,6 +537,18 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aArea !== null) {
+ if ($this->aArea->isModified() || $this->aArea->isNew()) {
+ $affectedRows += $this->aArea->save($con);
+ }
+ $this->setArea($this->aArea);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -550,21 +560,6 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->areasScheduledForDeletion !== null) {
- if (!$this->areasScheduledForDeletion->isEmpty()) {
- AreaQuery::create()
- ->filterByPrimaryKeys($this->areasScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->areasScheduledForDeletion = null;
- }
- }
-
- if ($this->singleArea !== null) {
- if (!$this->singleArea->isDeleted()) {
- $affectedRows += $this->singleArea->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -726,17 +721,23 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aArea !== null) {
+ if (!$this->aArea->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aArea->getValidationFailures());
+ }
+ }
+
+
if (($retval = DelivzonePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleArea !== null) {
- if (!$this->singleArea->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleArea->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -823,8 +824,8 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleArea) {
- $result['Area'] = $this->singleArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aArea) {
+ $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -995,11 +996,6 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getArea();
- if ($relObj) {
- $copyObj->setArea($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1050,55 +1046,57 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Area object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Area object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Area
- * @throws PropelException
- */
- public function getArea(PropelPDO $con = null)
- {
-
- if ($this->singleArea === null && !$this->isNew()) {
- $this->singleArea = AreaQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleArea;
- }
-
- /**
- * Sets a single Area object as related to this object by a one-to-one relationship.
- *
- * @param Area $v Area
+ * @param Area $v
* @return Delivzone The current object (for fluent API support)
* @throws PropelException
*/
public function setArea(Area $v = null)
{
- $this->singleArea = $v;
-
- // Make sure that that the passed-in Area isn't already associated with this object
- if ($v !== null && $v->getDelivzone() === null) {
- $v->setDelivzone($this);
+ if ($v === null) {
+ $this->setAreaId(NULL);
+ } else {
+ $this->setAreaId($v->getId());
}
+ $this->aArea = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Area object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDelivzone($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Area object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Area The associated Area object.
+ * @throws PropelException
+ */
+ public function getArea(PropelPDO $con = null)
+ {
+ if ($this->aArea === null && ($this->area_id !== null)) {
+ $this->aArea = AreaQuery::create()->findPk($this->area_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->aArea->addDelivzones($this);
+ */
+ }
+
+ return $this->aArea;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1129,15 +1127,9 @@ abstract class BaseDelivzone extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleArea) {
- $this->singleArea->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleArea instanceof PropelCollection) {
- $this->singleArea->clearIterator();
- }
- $this->singleArea = null;
+ $this->aArea = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseDelivzonePeer.php b/core/lib/Thelia/Model/om/BaseDelivzonePeer.php
index 0e0ee7dbc..c2cbaf9a0 100644
--- a/core/lib/Thelia/Model/om/BaseDelivzonePeer.php
+++ b/core/lib/Thelia/Model/om/BaseDelivzonePeer.php
@@ -25,7 +25,7 @@ abstract class BaseDelivzonePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'delivzone';
@@ -383,9 +383,6 @@ abstract class BaseDelivzonePeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in AreaPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- AreaPeer::clearInstancePool();
}
/**
@@ -482,6 +479,244 @@ abstract class BaseDelivzonePeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Area table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinArea(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DelivzonePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DelivzonePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DelivzonePeer::AREA_ID, AreaPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Delivzone objects pre-filled with their Area objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Delivzone objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinArea(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME);
+ }
+
+ DelivzonePeer::addSelectColumns($criteria);
+ $startcol = DelivzonePeer::NUM_HYDRATE_COLUMNS;
+ AreaPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(DelivzonePeer::AREA_ID, AreaPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DelivzonePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DelivzonePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = DelivzonePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DelivzonePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = AreaPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AreaPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ AreaPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Delivzone) to $obj2 (Area)
+ $obj2->addDelivzone($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DelivzonePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DelivzonePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DelivzonePeer::AREA_ID, AreaPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of Delivzone objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Delivzone objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME);
+ }
+
+ DelivzonePeer::addSelectColumns($criteria);
+ $startcol2 = DelivzonePeer::NUM_HYDRATE_COLUMNS;
+
+ AreaPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AreaPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(DelivzonePeer::AREA_ID, AreaPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DelivzonePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DelivzonePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = DelivzonePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DelivzonePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Area rows
+
+ $key2 = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = AreaPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = AreaPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ AreaPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (Delivzone) to the collection in $obj2 (Area)
+ $obj2->addDelivzone($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -615,7 +850,6 @@ abstract class BaseDelivzonePeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- DelivzonePeer::doOnDeleteSetNull(new Criteria(DelivzonePeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(DelivzonePeer::TABLE_NAME, $con, DelivzonePeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -649,14 +883,24 @@ abstract class BaseDelivzonePeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ DelivzonePeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Delivzone) { // it's a model object
+ // invalidate the cache for this single object
+ DelivzonePeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(DelivzonePeer::DATABASE_NAME);
$criteria->add(DelivzonePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ DelivzonePeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -669,23 +913,6 @@ abstract class BaseDelivzonePeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- DelivzonePeer::doOnDeleteSetNull($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- DelivzonePeer::clearInstancePool();
- } elseif ($values instanceof Delivzone) { // it's a model object
- DelivzonePeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- DelivzonePeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
DelivzonePeer::clearRelatedInstancePool();
$con->commit();
@@ -697,37 +924,6 @@ abstract class BaseDelivzonePeer
}
}
- /**
- * This is a method for emulating ON DELETE SET NULL DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return void
- */
- protected static function doOnDeleteSetNull(Criteria $criteria, PropelPDO $con)
- {
-
- // first find the objects that are implicated by the $criteria
- $objects = DelivzonePeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
- // set fkey col in related Area rows to null
- $selectCriteria = new Criteria(DelivzonePeer::DATABASE_NAME);
- $updateValues = new Criteria(DelivzonePeer::DATABASE_NAME);
- $selectCriteria->add(AreaPeer::ID, $obj->getAreaId());
- $updateValues->add(AreaPeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- }
- }
-
/**
* Validates all modified columns of given Delivzone object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php
index 40f89c9dd..abfaf373d 100644
--- a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php
+++ b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php
@@ -68,7 +68,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Delivzone', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Delivzone', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -271,6 +271,8 @@ abstract class BaseDelivzoneQuery extends ModelCriteria
* $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12
*
*
+ * @see filterByArea()
+ *
* @param mixed $areaId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -420,7 +422,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria
/**
* Filter the query by a related Area object
*
- * @param Area|PropelObjectCollection $area the related object to use as filter
+ * @param Area|PropelObjectCollection $area The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return DelivzoneQuery The current query, for fluid interface
@@ -432,10 +434,12 @@ abstract class BaseDelivzoneQuery extends ModelCriteria
return $this
->addUsingAlias(DelivzonePeer::AREA_ID, $area->getId(), $comparison);
} elseif ($area instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useAreaQuery()
- ->filterByPrimaryKeys($area->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(DelivzonePeer::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByArea() only accepts arguments of type Area or PropelCollection');
}
@@ -449,7 +453,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria
*
* @return DelivzoneQuery The current query, for fluid interface
*/
- public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Area');
@@ -484,7 +488,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria
*
* @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query
*/
- public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinArea($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseDocument.php b/core/lib/Thelia/Model/om/BaseDocument.php
index 38e1edaaa..cad17c959 100644
--- a/core/lib/Thelia/Model/om/BaseDocument.php
+++ b/core/lib/Thelia/Model/om/BaseDocument.php
@@ -112,29 +112,30 @@ abstract class BaseDocument extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var DocumentDesc
+ * @var Product
*/
- protected $aDocumentDesc;
+ protected $aProduct;
/**
- * @var Category one-to-one related Category object
+ * @var Category
*/
- protected $singleCategory;
+ protected $aCategory;
/**
- * @var Content one-to-one related Content object
+ * @var Content
*/
- protected $singleContent;
+ protected $aContent;
/**
- * @var Folder one-to-one related Folder object
+ * @var Folder
*/
- protected $singleFolder;
+ protected $aFolder;
/**
- * @var Product one-to-one related Product object
+ * @var PropelObjectCollection|DocumentDesc[] Collection to store aggregation of DocumentDesc objects.
*/
- protected $singleProduct;
+ protected $collDocumentDescs;
+ protected $collDocumentDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -154,25 +155,7 @@ abstract class BaseDocument extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $categorysScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $contentsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $foldersScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
+ protected $documentDescsScheduledForDeletion = null;
/**
* Get the [id] column value.
@@ -335,10 +318,6 @@ abstract class BaseDocument extends BaseObject implements Persistent
$this->modifiedColumns[] = DocumentPeer::ID;
}
- if ($this->aDocumentDesc !== null && $this->aDocumentDesc->getDocumentId() !== $v) {
- $this->aDocumentDesc = null;
- }
-
return $this;
} // setId()
@@ -360,6 +339,10 @@ abstract class BaseDocument extends BaseObject implements Persistent
$this->modifiedColumns[] = DocumentPeer::PRODUCT_ID;
}
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
return $this;
} // setProductId()
@@ -381,6 +364,10 @@ abstract class BaseDocument extends BaseObject implements Persistent
$this->modifiedColumns[] = DocumentPeer::CATEGORY_ID;
}
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
return $this;
} // setCategoryId()
@@ -402,6 +389,10 @@ abstract class BaseDocument extends BaseObject implements Persistent
$this->modifiedColumns[] = DocumentPeer::FOLDER_ID;
}
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
return $this;
} // setFolderId()
@@ -423,6 +414,10 @@ abstract class BaseDocument extends BaseObject implements Persistent
$this->modifiedColumns[] = DocumentPeer::CONTENT_ID;
}
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
return $this;
} // setContentId()
@@ -587,8 +582,17 @@ abstract class BaseDocument extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aDocumentDesc !== null && $this->id !== $this->aDocumentDesc->getDocumentId()) {
- $this->aDocumentDesc = null;
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
}
} // ensureConsistency
@@ -629,14 +633,11 @@ abstract class BaseDocument extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aDocumentDesc = null;
- $this->singleCategory = null;
-
- $this->singleContent = null;
-
- $this->singleFolder = null;
-
- $this->singleProduct = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ $this->collDocumentDescs = null;
} // if (deep)
}
@@ -756,11 +757,32 @@ abstract class BaseDocument extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aDocumentDesc !== null) {
- if ($this->aDocumentDesc->isModified() || $this->aDocumentDesc->isNew()) {
- $affectedRows += $this->aDocumentDesc->save($con);
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
}
- $this->setDocumentDesc($this->aDocumentDesc);
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
}
if ($this->isNew() || $this->isModified()) {
@@ -774,63 +796,20 @@ abstract class BaseDocument extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->categorysScheduledForDeletion !== null) {
- if (!$this->categorysScheduledForDeletion->isEmpty()) {
- CategoryQuery::create()
- ->filterByPrimaryKeys($this->categorysScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->documentDescsScheduledForDeletion !== null) {
+ if (!$this->documentDescsScheduledForDeletion->isEmpty()) {
+ DocumentDescQuery::create()
+ ->filterByPrimaryKeys($this->documentDescsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->categorysScheduledForDeletion = null;
+ $this->documentDescsScheduledForDeletion = null;
}
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->isDeleted()) {
- $affectedRows += $this->singleCategory->save($con);
- }
- }
-
- if ($this->contentsScheduledForDeletion !== null) {
- if (!$this->contentsScheduledForDeletion->isEmpty()) {
- ContentQuery::create()
- ->filterByPrimaryKeys($this->contentsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->contentsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->isDeleted()) {
- $affectedRows += $this->singleContent->save($con);
- }
- }
-
- if ($this->foldersScheduledForDeletion !== null) {
- if (!$this->foldersScheduledForDeletion->isEmpty()) {
- FolderQuery::create()
- ->filterByPrimaryKeys($this->foldersScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->foldersScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->isDeleted()) {
- $affectedRows += $this->singleFolder->save($con);
- }
- }
-
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
+ if ($this->collDocumentDescs !== null) {
+ foreach ($this->collDocumentDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
}
}
@@ -1024,9 +1003,27 @@ abstract class BaseDocument extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aDocumentDesc !== null) {
- if (!$this->aDocumentDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aDocumentDesc->getValidationFailures());
+ if ($this->aProduct !== null) {
+ if (!$this->aProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
+ }
+ }
+
+ if ($this->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+ if ($this->aContent !== null) {
+ if (!$this->aContent->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures());
+ }
+ }
+
+ if ($this->aFolder !== null) {
+ if (!$this->aFolder->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures());
}
}
@@ -1036,27 +1033,11 @@ abstract class BaseDocument extends BaseObject implements Persistent
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCategory->getValidationFailures());
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleContent->getValidationFailures());
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFolder->getValidationFailures());
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
+ if ($this->collDocumentDescs !== null) {
+ foreach ($this->collDocumentDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
}
}
@@ -1162,20 +1143,20 @@ abstract class BaseDocument extends BaseObject implements Persistent
$keys[8] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aDocumentDesc) {
- $result['DocumentDesc'] = $this->aDocumentDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleCategory) {
- $result['Category'] = $this->singleCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleContent) {
- $result['Content'] = $this->singleContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleFolder) {
- $result['Folder'] = $this->singleFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collDocumentDescs) {
+ $result['DocumentDescs'] = $this->collDocumentDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1370,29 +1351,10 @@ abstract class BaseDocument extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCategory();
- if ($relObj) {
- $copyObj->setCategory($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getContent();
- if ($relObj) {
- $copyObj->setContent($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getFolder();
- if ($relObj) {
- $copyObj->setFolder($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getDocumentDesc();
- if ($relObj) {
- $copyObj->setDocumentDesc($relObj->copy($deepCopy));
+ foreach ($this->getDocumentDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocumentDesc($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1446,25 +1408,26 @@ abstract class BaseDocument extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a DocumentDesc object.
+ * Declares an association between this object and a Product object.
*
- * @param DocumentDesc $v
+ * @param Product $v
* @return Document The current object (for fluent API support)
* @throws PropelException
*/
- public function setDocumentDesc(DocumentDesc $v = null)
+ public function setProduct(Product $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setProductId(NULL);
} else {
- $this->setId($v->getDocumentId());
+ $this->setProductId($v->getId());
}
- $this->aDocumentDesc = $v;
+ $this->aProduct = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // 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 ($v !== null) {
- $v->setDocument($this);
+ $v->addDocument($this);
}
@@ -1473,23 +1436,179 @@ abstract class BaseDocument extends BaseObject implements Persistent
/**
- * Get the associated DocumentDesc object
+ * Get the associated Product object
*
* @param PropelPDO $con Optional Connection object.
- * @return DocumentDesc The associated DocumentDesc object.
+ * @return Product The associated Product object.
* @throws PropelException
*/
- public function getDocumentDesc(PropelPDO $con = null)
+ public function getProduct(PropelPDO $con = null)
{
- if ($this->aDocumentDesc === null && ($this->id !== null)) {
- $this->aDocumentDesc = DocumentDescQuery::create()
- ->filterByDocument($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aDocumentDesc->setDocument($this);
+ 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->aProduct->addDocuments($this);
+ */
}
- return $this->aDocumentDesc;
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return Document The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(Category $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Category object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocument($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Category object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Category The associated Category object.
+ * @throws PropelException
+ */
+ public function getCategory(PropelPDO $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->category_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->aCategory->addDocuments($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a Content object.
+ *
+ * @param Content $v
+ * @return Document The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(Content $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Content object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocument($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Content object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Content The associated Content object.
+ * @throws PropelException
+ */
+ public function getContent(PropelPDO $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ContentQuery::create()->findPk($this->content_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->aContent->addDocuments($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Declares an association between this object and a Folder object.
+ *
+ * @param Folder $v
+ * @return Document The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(Folder $v = null)
+ {
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Folder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocument($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Folder object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Folder The associated Folder object.
+ * @throws PropelException
+ */
+ public function getFolder(PropelPDO $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = FolderQuery::create()->findPk($this->folder_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->aFolder->addDocuments($this);
+ */
+ }
+
+ return $this->aFolder;
}
@@ -1503,150 +1622,216 @@ abstract class BaseDocument extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ if ('DocumentDesc' == $relationName) {
+ $this->initDocumentDescs();
+ }
}
/**
- * Gets a single Category object, which is related to this object by a one-to-one relationship.
+ * Clears out the collDocumentDescs 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 addDocumentDescs()
+ */
+ public function clearDocumentDescs()
+ {
+ $this->collDocumentDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collDocumentDescsPartial = null;
+ }
+
+ /**
+ * reset is the collDocumentDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialDocumentDescs($v = true)
+ {
+ $this->collDocumentDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collDocumentDescs collection.
+ *
+ * By default this just sets the collDocumentDescs collection to an empty array (like clearcollDocumentDescs());
+ * 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 initDocumentDescs($overrideExisting = true)
+ {
+ if (null !== $this->collDocumentDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collDocumentDescs = new PropelObjectCollection();
+ $this->collDocumentDescs->setModel('DocumentDesc');
+ }
+
+ /**
+ * Gets an array of DocumentDesc 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 Document 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 Category
+ * @return PropelObjectCollection|DocumentDesc[] List of DocumentDesc objects
* @throws PropelException
*/
- public function getCategory(PropelPDO $con = null)
+ public function getDocumentDescs($criteria = null, PropelPDO $con = null)
{
+ $partial = $this->collDocumentDescsPartial && !$this->isNew();
+ if (null === $this->collDocumentDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocumentDescs) {
+ // return empty collection
+ $this->initDocumentDescs();
+ } else {
+ $collDocumentDescs = DocumentDescQuery::create(null, $criteria)
+ ->filterByDocument($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentDescsPartial && count($collDocumentDescs)) {
+ $this->initDocumentDescs(false);
- if ($this->singleCategory === null && !$this->isNew()) {
- $this->singleCategory = CategoryQuery::create()->findPk($this->getPrimaryKey(), $con);
+ foreach($collDocumentDescs as $obj) {
+ if (false == $this->collDocumentDescs->contains($obj)) {
+ $this->collDocumentDescs->append($obj);
+ }
+ }
+
+ $this->collDocumentDescsPartial = true;
+ }
+
+ return $collDocumentDescs;
+ }
+
+ if($partial && $this->collDocumentDescs) {
+ foreach($this->collDocumentDescs as $obj) {
+ if($obj->isNew()) {
+ $collDocumentDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocumentDescs = $collDocumentDescs;
+ $this->collDocumentDescsPartial = false;
+ }
}
- return $this->singleCategory;
+ return $this->collDocumentDescs;
}
/**
- * Sets a single Category object as related to this object by a one-to-one relationship.
+ * Sets a collection of DocumentDesc 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 Category $v Category
- * @return Document The current object (for fluent API support)
+ * @param PropelCollection $documentDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setDocumentDescs(PropelCollection $documentDescs, PropelPDO $con = null)
+ {
+ $this->documentDescsScheduledForDeletion = $this->getDocumentDescs(new Criteria(), $con)->diff($documentDescs);
+
+ foreach ($this->documentDescsScheduledForDeletion as $documentDescRemoved) {
+ $documentDescRemoved->setDocument(null);
+ }
+
+ $this->collDocumentDescs = null;
+ foreach ($documentDescs as $documentDesc) {
+ $this->addDocumentDesc($documentDesc);
+ }
+
+ $this->collDocumentDescs = $documentDescs;
+ $this->collDocumentDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related DocumentDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related DocumentDesc objects.
* @throws PropelException
*/
- public function setCategory(Category $v = null)
+ public function countDocumentDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleCategory = $v;
+ $partial = $this->collDocumentDescsPartial && !$this->isNew();
+ if (null === $this->collDocumentDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocumentDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getDocumentDescs());
+ }
+ $query = DocumentDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
- // Make sure that that the passed-in Category isn't already associated with this object
- if ($v !== null && $v->getDocument() === null) {
- $v->setDocument($this);
+ return $query
+ ->filterByDocument($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collDocumentDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a DocumentDesc object to this object
+ * through the DocumentDesc foreign key attribute.
+ *
+ * @param DocumentDesc $l DocumentDesc
+ * @return Document The current object (for fluent API support)
+ */
+ public function addDocumentDesc(DocumentDesc $l)
+ {
+ if ($this->collDocumentDescs === null) {
+ $this->initDocumentDescs();
+ $this->collDocumentDescsPartial = true;
+ }
+ if (!$this->collDocumentDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddDocumentDesc($l);
}
return $this;
}
/**
- * Gets a single Content object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Content
- * @throws PropelException
+ * @param DocumentDesc $documentDesc The documentDesc object to add.
*/
- public function getContent(PropelPDO $con = null)
+ protected function doAddDocumentDesc($documentDesc)
{
-
- if ($this->singleContent === null && !$this->isNew()) {
- $this->singleContent = ContentQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleContent;
+ $this->collDocumentDescs[]= $documentDesc;
+ $documentDesc->setDocument($this);
}
/**
- * Sets a single Content object as related to this object by a one-to-one relationship.
- *
- * @param Content $v Content
- * @return Document The current object (for fluent API support)
- * @throws PropelException
+ * @param DocumentDesc $documentDesc The documentDesc object to remove.
*/
- public function setContent(Content $v = null)
+ public function removeDocumentDesc($documentDesc)
{
- $this->singleContent = $v;
-
- // Make sure that that the passed-in Content isn't already associated with this object
- if ($v !== null && $v->getDocument() === null) {
- $v->setDocument($this);
+ if ($this->getDocumentDescs()->contains($documentDesc)) {
+ $this->collDocumentDescs->remove($this->collDocumentDescs->search($documentDesc));
+ if (null === $this->documentDescsScheduledForDeletion) {
+ $this->documentDescsScheduledForDeletion = clone $this->collDocumentDescs;
+ $this->documentDescsScheduledForDeletion->clear();
+ }
+ $this->documentDescsScheduledForDeletion[]= $documentDesc;
+ $documentDesc->setDocument(null);
}
-
- return $this;
- }
-
- /**
- * Gets a single Folder object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Folder
- * @throws PropelException
- */
- public function getFolder(PropelPDO $con = null)
- {
-
- if ($this->singleFolder === null && !$this->isNew()) {
- $this->singleFolder = FolderQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleFolder;
- }
-
- /**
- * Sets a single Folder object as related to this object by a one-to-one relationship.
- *
- * @param Folder $v Folder
- * @return Document The current object (for fluent API support)
- * @throws PropelException
- */
- public function setFolder(Folder $v = null)
- {
- $this->singleFolder = $v;
-
- // Make sure that that the passed-in Folder isn't already associated with this object
- if ($v !== null && $v->getDocument() === null) {
- $v->setDocument($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Product
- * @throws PropelException
- */
- public function getProduct(PropelPDO $con = null)
- {
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleProduct;
- }
-
- /**
- * Sets a single Product object as related to this object by a one-to-one relationship.
- *
- * @param Product $v Product
- * @return Document The current object (for fluent API support)
- * @throws PropelException
- */
- public function setProduct(Product $v = null)
- {
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getDocument() === null) {
- $v->setDocument($this);
- }
-
- return $this;
}
/**
@@ -1683,37 +1868,21 @@ abstract class BaseDocument extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCategory) {
- $this->singleCategory->clearAllReferences($deep);
- }
- if ($this->singleContent) {
- $this->singleContent->clearAllReferences($deep);
- }
- if ($this->singleFolder) {
- $this->singleFolder->clearAllReferences($deep);
- }
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
+ if ($this->collDocumentDescs) {
+ foreach ($this->collDocumentDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
}
} // if ($deep)
- if ($this->singleCategory instanceof PropelCollection) {
- $this->singleCategory->clearIterator();
+ if ($this->collDocumentDescs instanceof PropelCollection) {
+ $this->collDocumentDescs->clearIterator();
}
- $this->singleCategory = null;
- if ($this->singleContent instanceof PropelCollection) {
- $this->singleContent->clearIterator();
- }
- $this->singleContent = null;
- if ($this->singleFolder instanceof PropelCollection) {
- $this->singleFolder->clearIterator();
- }
- $this->singleFolder = null;
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
- $this->aDocumentDesc = null;
+ $this->collDocumentDescs = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseDocumentDesc.php b/core/lib/Thelia/Model/om/BaseDocumentDesc.php
index 4221d62a5..3c341edc7 100644
--- a/core/lib/Thelia/Model/om/BaseDocumentDesc.php
+++ b/core/lib/Thelia/Model/om/BaseDocumentDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Document;
use Thelia\Model\DocumentDesc;
@@ -98,9 +96,9 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Document one-to-one related Document object
+ * @var Document
*/
- protected $singleDocument;
+ protected $aDocument;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $documentsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -294,6 +286,10 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = DocumentDescPeer::DOCUMENT_ID;
}
+ if ($this->aDocument !== null && $this->aDocument->getId() !== $v) {
+ $this->aDocument = null;
+ }
+
return $this;
} // setDocumentId()
@@ -499,6 +495,9 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aDocument !== null && $this->document_id !== $this->aDocument->getId()) {
+ $this->aDocument = null;
+ }
} // ensureConsistency
/**
@@ -538,8 +537,7 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleDocument = null;
-
+ $this->aDocument = null;
} // if (deep)
}
@@ -653,6 +651,18 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aDocument !== null) {
+ if ($this->aDocument->isModified() || $this->aDocument->isNew()) {
+ $affectedRows += $this->aDocument->save($con);
+ }
+ $this->setDocument($this->aDocument);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -664,21 +674,6 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->documentsScheduledForDeletion !== null) {
- if (!$this->documentsScheduledForDeletion->isEmpty()) {
- DocumentQuery::create()
- ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->documentsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleDocument !== null) {
- if (!$this->singleDocument->isDeleted()) {
- $affectedRows += $this->singleDocument->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -858,17 +853,23 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aDocument !== null) {
+ if (!$this->aDocument->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aDocument->getValidationFailures());
+ }
+ }
+
+
if (($retval = DocumentDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleDocument !== null) {
- if (!$this->singleDocument->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleDocument->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -967,8 +968,8 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleDocument) {
- $result['Document'] = $this->singleDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aDocument) {
+ $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1157,11 +1158,6 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getDocument();
- if ($relObj) {
- $copyObj->setDocument($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1212,55 +1208,57 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Document object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Document object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Document
- * @throws PropelException
- */
- public function getDocument(PropelPDO $con = null)
- {
-
- if ($this->singleDocument === null && !$this->isNew()) {
- $this->singleDocument = DocumentQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleDocument;
- }
-
- /**
- * Sets a single Document object as related to this object by a one-to-one relationship.
- *
- * @param Document $v Document
+ * @param Document $v
* @return DocumentDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setDocument(Document $v = null)
{
- $this->singleDocument = $v;
-
- // Make sure that that the passed-in Document isn't already associated with this object
- if ($v !== null && $v->getDocumentDesc() === null) {
- $v->setDocumentDesc($this);
+ if ($v === null) {
+ $this->setDocumentId(NULL);
+ } else {
+ $this->setDocumentId($v->getId());
}
+ $this->aDocument = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Document object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocumentDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Document object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Document The associated Document object.
+ * @throws PropelException
+ */
+ public function getDocument(PropelPDO $con = null)
+ {
+ if ($this->aDocument === null && ($this->document_id !== null)) {
+ $this->aDocument = DocumentQuery::create()->findPk($this->document_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->aDocument->addDocumentDescs($this);
+ */
+ }
+
+ return $this->aDocument;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1294,15 +1292,9 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleDocument) {
- $this->singleDocument->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleDocument instanceof PropelCollection) {
- $this->singleDocument->clearIterator();
- }
- $this->singleDocument = null;
+ $this->aDocument = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseDocumentDescPeer.php b/core/lib/Thelia/Model/om/BaseDocumentDescPeer.php
index 981d71560..013588697 100644
--- a/core/lib/Thelia/Model/om/BaseDocumentDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseDocumentDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseDocumentDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'document_desc';
@@ -398,9 +398,6 @@ abstract class BaseDocumentDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in DocumentPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- DocumentPeer::clearInstancePool();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseDocumentDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Document table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinDocument(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentDescPeer::DOCUMENT_ID, DocumentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of DocumentDesc objects pre-filled with their Document objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of DocumentDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME);
+ }
+
+ DocumentDescPeer::addSelectColumns($criteria);
+ $startcol = DocumentDescPeer::NUM_HYDRATE_COLUMNS;
+ DocumentPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(DocumentDescPeer::DOCUMENT_ID, DocumentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = DocumentDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = DocumentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = DocumentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ DocumentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (DocumentDesc) to $obj2 (Document)
+ $obj2->addDocumentDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentDescPeer::DOCUMENT_ID, DocumentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of DocumentDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of DocumentDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME);
+ }
+
+ DocumentDescPeer::addSelectColumns($criteria);
+ $startcol2 = DocumentDescPeer::NUM_HYDRATE_COLUMNS;
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + DocumentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(DocumentDescPeer::DOCUMENT_ID, DocumentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = DocumentDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Document rows
+
+ $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = DocumentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = DocumentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ DocumentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (DocumentDesc) to the collection in $obj2 (Document)
+ $obj2->addDocumentDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -630,7 +865,6 @@ abstract class BaseDocumentDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += DocumentDescPeer::doOnDeleteCascade(new Criteria(DocumentDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(DocumentDescPeer::TABLE_NAME, $con, DocumentDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +898,24 @@ abstract class BaseDocumentDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ DocumentDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof DocumentDesc) { // it's a model object
+ // invalidate the cache for this single object
+ DocumentDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(DocumentDescPeer::DATABASE_NAME);
$criteria->add(DocumentDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ DocumentDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,23 +928,6 @@ abstract class BaseDocumentDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += DocumentDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- DocumentDescPeer::clearInstancePool();
- } elseif ($values instanceof DocumentDesc) { // it's a model object
- DocumentDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- DocumentDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
DocumentDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -712,39 +939,6 @@ abstract class BaseDocumentDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = DocumentDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Document objects
- $criteria = new Criteria(DocumentPeer::DATABASE_NAME);
-
- $criteria->add(DocumentPeer::ID, $obj->getDocumentId());
- $affectedRows += DocumentPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given DocumentDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php b/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php
index 1f02c74d6..5d1597689 100644
--- a/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseDocumentDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\DocumentDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\DocumentDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -283,6 +283,8 @@ abstract class BaseDocumentDescQuery extends ModelCriteria
* $query->filterByDocumentId(array('min' => 12)); // WHERE document_id > 12
*
*
+ * @see filterByDocument()
+ *
* @param mixed $documentId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +521,7 @@ abstract class BaseDocumentDescQuery extends ModelCriteria
/**
* Filter the query by a related Document object
*
- * @param Document|PropelObjectCollection $document the related object to use as filter
+ * @param Document|PropelObjectCollection $document The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return DocumentDescQuery The current query, for fluid interface
@@ -531,10 +533,12 @@ abstract class BaseDocumentDescQuery extends ModelCriteria
return $this
->addUsingAlias(DocumentDescPeer::DOCUMENT_ID, $document->getId(), $comparison);
} elseif ($document instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useDocumentQuery()
- ->filterByPrimaryKeys($document->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(DocumentDescPeer::DOCUMENT_ID, $document->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseDocumentPeer.php b/core/lib/Thelia/Model/om/BaseDocumentPeer.php
index f5162ef34..0f8da5499 100644
--- a/core/lib/Thelia/Model/om/BaseDocumentPeer.php
+++ b/core/lib/Thelia/Model/om/BaseDocumentPeer.php
@@ -29,7 +29,7 @@ abstract class BaseDocumentPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'document';
@@ -407,18 +407,9 @@ abstract class BaseDocumentPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CategoryPeer instance pool,
+ // Invalidate objects in DocumentDescPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CategoryPeer::clearInstancePool();
- // Invalidate objects in ContentPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ContentPeer::clearInstancePool();
- // Invalidate objects in FolderPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FolderPeer::clearInstancePool();
- // Invalidate objects in ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
+ DocumentDescPeer::clearInstancePool();
}
/**
@@ -517,7 +508,7 @@ abstract class BaseDocumentPeer
/**
- * Returns the number of rows matching criteria, joining the related DocumentDesc 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.
@@ -525,7 +516,7 @@ abstract class BaseDocumentPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinDocumentDesc(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;
@@ -552,7 +543,7 @@ abstract class BaseDocumentPeer
$con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(DocumentPeer::ID, DocumentDescPeer::DOCUMENT_ID, $join_behavior);
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -568,7 +559,160 @@ abstract class BaseDocumentPeer
/**
- * Selects a collection of Document objects pre-filled with their DocumentDesc objects.
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Document 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
@@ -576,7 +720,7 @@ abstract class BaseDocumentPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinDocumentDesc(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;
@@ -587,9 +731,9 @@ abstract class BaseDocumentPeer
DocumentPeer::addSelectColumns($criteria);
$startcol = DocumentPeer::NUM_HYDRATE_COLUMNS;
- DocumentDescPeer::addSelectColumns($criteria);
+ ProductPeer::addSelectColumns($criteria);
- $criteria->addJoin(DocumentPeer::ID, DocumentDescPeer::DOCUMENT_ID, $join_behavior);
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -609,21 +753,221 @@ abstract class BaseDocumentPeer
DocumentPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = DocumentDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = DocumentDescPeer::getInstanceFromPool($key2);
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = DocumentDescPeer::getOMClass();
+ $cls = ProductPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- DocumentDescPeer::addInstanceToPool($obj2, $key2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (Document) to $obj2 (DocumentDesc)
- // one to one relationship
- $obj1->setDocumentDesc($obj2);
+ // Add the $obj1 (Document) to $obj2 (Product)
+ $obj2->addDocument($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Document objects pre-filled with their Category objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Document objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+ }
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol = DocumentPeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = DocumentPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Document) to $obj2 (Category)
+ $obj2->addDocument($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Document objects pre-filled with their Content objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Document objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+ }
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol = DocumentPeer::NUM_HYDRATE_COLUMNS;
+ ContentPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = DocumentPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Document) to $obj2 (Content)
+ $obj2->addDocument($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Document objects pre-filled with their Folder objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Document objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+ }
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol = DocumentPeer::NUM_HYDRATE_COLUMNS;
+ FolderPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = DocumentPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FolderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FolderPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Document) to $obj2 (Folder)
+ $obj2->addDocument($obj1);
} // if joined row was not null
@@ -671,7 +1015,13 @@ abstract class BaseDocumentPeer
$con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(DocumentPeer::ID, DocumentDescPeer::DOCUMENT_ID, $join_behavior);
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -707,10 +1057,25 @@ abstract class BaseDocumentPeer
DocumentPeer::addSelectColumns($criteria);
$startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS;
- DocumentDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + DocumentDescPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
- $criteria->addJoin(DocumentPeer::ID, DocumentDescPeer::DOCUMENT_ID, $join_behavior);
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol6 = $startcol5 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -729,24 +1094,786 @@ abstract class BaseDocumentPeer
DocumentPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined DocumentDesc rows
+ // Add objects for joined Product rows
- $key2 = DocumentDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = DocumentDescPeer::getInstanceFromPool($key2);
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = DocumentDescPeer::getOMClass();
+ $cls = ProductPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- DocumentDescPeer::addInstanceToPool($obj2, $key2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (Document) to the collection in $obj2 (DocumentDesc)
- $obj1->setDocumentDesc($obj2);
+ // Add the $obj1 (Document) to the collection in $obj2 (Product)
+ $obj2->addDocument($obj1);
} // if joined row not null
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (Document) to the collection in $obj3 (Category)
+ $obj3->addDocument($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Content rows
+
+ $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ContentPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ContentPeer::addInstanceToPool($obj4, $key4);
+ } // if obj4 loaded
+
+ // Add the $obj1 (Document) to the collection in $obj4 (Content)
+ $obj4->addDocument($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Folder rows
+
+ $key5 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol5);
+ if ($key5 !== null) {
+ $obj5 = FolderPeer::getInstanceFromPool($key5);
+ if (!$obj5) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj5 = new $cls();
+ $obj5->hydrate($row, $startcol5);
+ FolderPeer::addInstanceToPool($obj5, $key5);
+ } // if obj5 loaded
+
+ // Add the $obj1 (Document) to the collection in $obj5 (Folder)
+ $obj5->addDocument($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ DocumentPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Document objects pre-filled with all related objects except Product.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Document objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+ }
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = DocumentPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj2 (Category)
+ $obj2->addDocument($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ContentPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ContentPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj3 (Content)
+ $obj3->addDocument($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = FolderPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ FolderPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj4 (Folder)
+ $obj4->addDocument($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Document objects pre-filled with all related objects except Category.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Document objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+ }
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = DocumentPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj2 (Product)
+ $obj2->addDocument($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ContentPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ContentPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj3 (Content)
+ $obj3->addDocument($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = FolderPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ FolderPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj4 (Folder)
+ $obj4->addDocument($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Document objects pre-filled with all related objects except Content.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Document objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+ }
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = DocumentPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj2 (Product)
+ $obj2->addDocument($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj3 (Category)
+ $obj3->addDocument($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = FolderPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ FolderPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj4 (Folder)
+ $obj4->addDocument($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Document objects pre-filled with all related objects except Folder.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Document objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+ }
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = DocumentPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ DocumentPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj2 (Product)
+ $obj2->addDocument($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj3 (Category)
+ $obj3->addDocument($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ContentPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ContentPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Document) to the collection in $obj4 (Content)
+ $obj4->addDocument($obj1);
+
+ } // if joined row is not null
+
$results[] = $obj1;
}
$stmt->closeCursor();
@@ -887,7 +2014,6 @@ abstract class BaseDocumentPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += DocumentPeer::doOnDeleteCascade(new Criteria(DocumentPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(DocumentPeer::TABLE_NAME, $con, DocumentPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -921,14 +2047,24 @@ abstract class BaseDocumentPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ DocumentPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Document) { // it's a model object
+ // invalidate the cache for this single object
+ DocumentPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(DocumentPeer::DATABASE_NAME);
$criteria->add(DocumentPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ DocumentPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -941,23 +2077,6 @@ abstract class BaseDocumentPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += DocumentPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- DocumentPeer::clearInstancePool();
- } elseif ($values instanceof Document) { // it's a model object
- DocumentPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- DocumentPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
DocumentPeer::clearRelatedInstancePool();
$con->commit();
@@ -969,57 +2088,6 @@ abstract class BaseDocumentPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = DocumentPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Category objects
- $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
-
- $criteria->add(CategoryPeer::ID, $obj->getCategoryId());
- $affectedRows += CategoryPeer::doDelete($criteria, $con);
-
- // delete related Content objects
- $criteria = new Criteria(ContentPeer::DATABASE_NAME);
-
- $criteria->add(ContentPeer::ID, $obj->getContentId());
- $affectedRows += ContentPeer::doDelete($criteria, $con);
-
- // delete related Folder objects
- $criteria = new Criteria(FolderPeer::DATABASE_NAME);
-
- $criteria->add(FolderPeer::ID, $obj->getFolderId());
- $affectedRows += FolderPeer::doDelete($criteria, $con);
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given Document object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseDocumentQuery.php b/core/lib/Thelia/Model/om/BaseDocumentQuery.php
index 1caff3b73..ce4457035 100644
--- a/core/lib/Thelia/Model/om/BaseDocumentQuery.php
+++ b/core/lib/Thelia/Model/om/BaseDocumentQuery.php
@@ -50,9 +50,9 @@ use Thelia\Model\Product;
* @method DocumentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method DocumentQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method DocumentQuery leftJoinDocumentDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the DocumentDesc relation
- * @method DocumentQuery rightJoinDocumentDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DocumentDesc relation
- * @method DocumentQuery innerJoinDocumentDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the DocumentDesc relation
+ * @method DocumentQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
+ * @method DocumentQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
+ * @method DocumentQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
*
* @method DocumentQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
* @method DocumentQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
@@ -66,9 +66,9 @@ use Thelia\Model\Product;
* @method DocumentQuery rightJoinFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Folder relation
* @method DocumentQuery innerJoinFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the Folder relation
*
- * @method DocumentQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
- * @method DocumentQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
- * @method DocumentQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
+ * @method DocumentQuery leftJoinDocumentDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the DocumentDesc relation
+ * @method DocumentQuery rightJoinDocumentDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DocumentDesc relation
+ * @method DocumentQuery innerJoinDocumentDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the DocumentDesc relation
*
* @method Document findOne(PropelPDO $con = null) Return the first Document matching the query
* @method Document findOneOrCreate(PropelPDO $con = null) Return the first Document matching the query, or a new Document object populated from the query conditions when no match is found
@@ -104,7 +104,7 @@ abstract class BaseDocumentQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Document', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Document', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -280,8 +280,6 @@ abstract class BaseDocumentQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByDocumentDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -309,6 +307,8 @@ abstract class BaseDocumentQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProduct()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -350,6 +350,8 @@ abstract class BaseDocumentQuery extends ModelCriteria
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
*
*
+ * @see filterByCategory()
+ *
* @param mixed $categoryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -391,6 +393,8 @@ abstract class BaseDocumentQuery extends ModelCriteria
* $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
*
*
+ * @see filterByFolder()
+ *
* @param mixed $folderId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -432,6 +436,8 @@ abstract class BaseDocumentQuery extends ModelCriteria
* $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
*
*
+ * @see filterByContent()
+ *
* @param mixed $contentId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -619,10 +625,314 @@ abstract class BaseDocumentQuery extends ModelCriteria
return $this->addUsingAlias(DocumentPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query by a related Product object
+ *
+ * @param Product|PropelObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof Product) {
+ return $this
+ ->addUsingAlias(DocumentPeer::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 DocumentQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // 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, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product 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\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related Category object
+ *
+ * @param Category|PropelObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof Category) {
+ return $this
+ ->addUsingAlias(DocumentPeer::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // 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, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related Content object
+ *
+ * @param Content|PropelObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof Content) {
+ return $this
+ ->addUsingAlias(DocumentPeer::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // 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, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content 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\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Filter the query by a related Folder object
+ *
+ * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof Folder) {
+ return $this
+ ->addUsingAlias(DocumentPeer::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // 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, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder 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\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
/**
* Filter the query by a related DocumentDesc object
*
- * @param DocumentDesc|PropelObjectCollection $documentDesc The related object(s) to use as filter
+ * @param DocumentDesc|PropelObjectCollection $documentDesc the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return DocumentQuery The current query, for fluid interface
@@ -634,12 +944,10 @@ abstract class BaseDocumentQuery extends ModelCriteria
return $this
->addUsingAlias(DocumentPeer::ID, $documentDesc->getDocumentId(), $comparison);
} elseif ($documentDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(DocumentPeer::ID, $documentDesc->toKeyValue('PrimaryKey', 'DocumentId'), $comparison);
+ ->useDocumentDescQuery()
+ ->filterByPrimaryKeys($documentDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByDocumentDesc() only accepts arguments of type DocumentDesc or PropelCollection');
}
@@ -695,302 +1003,6 @@ abstract class BaseDocumentQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'DocumentDesc', '\Thelia\Model\DocumentDescQuery');
}
- /**
- * Filter the query by a related Category object
- *
- * @param Category|PropelObjectCollection $category the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return DocumentQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByCategory($category, $comparison = null)
- {
- if ($category instanceof Category) {
- return $this
- ->addUsingAlias(DocumentPeer::CATEGORY_ID, $category->getId(), $comparison);
- } elseif ($category instanceof PropelObjectCollection) {
- return $this
- ->useCategoryQuery()
- ->filterByPrimaryKeys($category->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Category relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return DocumentQuery The current query, for fluid interface
- */
- public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Category');
-
- // 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, 'Category');
- }
-
- return $this;
- }
-
- /**
- * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query
- */
- public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinCategory($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
- }
-
- /**
- * Filter the query by a related Content object
- *
- * @param Content|PropelObjectCollection $content the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return DocumentQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByContent($content, $comparison = null)
- {
- if ($content instanceof Content) {
- return $this
- ->addUsingAlias(DocumentPeer::CONTENT_ID, $content->getId(), $comparison);
- } elseif ($content instanceof PropelObjectCollection) {
- return $this
- ->useContentQuery()
- ->filterByPrimaryKeys($content->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Content relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return DocumentQuery The current query, for fluid interface
- */
- public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Content');
-
- // 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, 'Content');
- }
-
- return $this;
- }
-
- /**
- * Use the Content relation Content 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\ContentQuery A secondary query class using the current class as primary query
- */
- public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinContent($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
- }
-
- /**
- * Filter the query by a related Folder object
- *
- * @param Folder|PropelObjectCollection $folder the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return DocumentQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByFolder($folder, $comparison = null)
- {
- if ($folder instanceof Folder) {
- return $this
- ->addUsingAlias(DocumentPeer::FOLDER_ID, $folder->getId(), $comparison);
- } elseif ($folder instanceof PropelObjectCollection) {
- return $this
- ->useFolderQuery()
- ->filterByPrimaryKeys($folder->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Folder relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return DocumentQuery The current query, for fluid interface
- */
- public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Folder');
-
- // 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, 'Folder');
- }
-
- return $this;
- }
-
- /**
- * Use the Folder relation Folder 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\FolderQuery A secondary query class using the current class as primary query
- */
- public function useFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinFolder($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
- }
-
- /**
- * Filter the query by a related Product object
- *
- * @param Product|PropelObjectCollection $product the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return DocumentQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByProduct($product, $comparison = null)
- {
- if ($product instanceof Product) {
- return $this
- ->addUsingAlias(DocumentPeer::PRODUCT_ID, $product->getId(), $comparison);
- } elseif ($product instanceof PropelObjectCollection) {
- return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
- }
- }
-
- /**
- * 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 DocumentQuery The current query, for fluid interface
- */
- public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Product');
-
- // 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, 'Product');
- }
-
- return $this;
- }
-
- /**
- * Use the Product relation Product 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\ProductQuery A secondary query class using the current class as primary query
- */
- public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinProduct($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
- }
-
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseFeature.php b/core/lib/Thelia/Model/om/BaseFeature.php
index 8bc7cbb69..773ad7232 100644
--- a/core/lib/Thelia/Model/om/BaseFeature.php
+++ b/core/lib/Thelia/Model/om/BaseFeature.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Feature;
use Thelia\Model\FeatureAv;
@@ -85,24 +87,28 @@ abstract class BaseFeature extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var FeatureAv
+ * @var PropelObjectCollection|FeatureAv[] Collection to store aggregation of FeatureAv objects.
*/
- protected $aFeatureAv;
+ protected $collFeatureAvs;
+ protected $collFeatureAvsPartial;
/**
- * @var FeatureCategory
+ * @var PropelObjectCollection|FeatureCategory[] Collection to store aggregation of FeatureCategory objects.
*/
- protected $aFeatureCategory;
+ protected $collFeatureCategorys;
+ protected $collFeatureCategorysPartial;
/**
- * @var FeatureDesc
+ * @var PropelObjectCollection|FeatureDesc[] Collection to store aggregation of FeatureDesc objects.
*/
- protected $aFeatureDesc;
+ protected $collFeatureDescs;
+ protected $collFeatureDescsPartial;
/**
- * @var FeatureProd
+ * @var PropelObjectCollection|FeatureProd[] Collection to store aggregation of FeatureProd objects.
*/
- protected $aFeatureProd;
+ protected $collFeatureProds;
+ protected $collFeatureProdsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -118,6 +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 $featureProdsScheduledForDeletion = null;
+
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
@@ -260,22 +290,6 @@ abstract class BaseFeature extends BaseObject implements Persistent
$this->modifiedColumns[] = FeaturePeer::ID;
}
- if ($this->aFeatureAv !== null && $this->aFeatureAv->getFeatureId() !== $v) {
- $this->aFeatureAv = null;
- }
-
- if ($this->aFeatureCategory !== null && $this->aFeatureCategory->getFeatureId() !== $v) {
- $this->aFeatureCategory = null;
- }
-
- if ($this->aFeatureDesc !== null && $this->aFeatureDesc->getFeatureId() !== $v) {
- $this->aFeatureDesc = null;
- }
-
- if ($this->aFeatureProd !== null && $this->aFeatureProd->getFeatureId() !== $v) {
- $this->aFeatureProd = null;
- }
-
return $this;
} // setId()
@@ -440,18 +454,6 @@ abstract class BaseFeature extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aFeatureAv !== null && $this->id !== $this->aFeatureAv->getFeatureId()) {
- $this->aFeatureAv = null;
- }
- if ($this->aFeatureCategory !== null && $this->id !== $this->aFeatureCategory->getFeatureId()) {
- $this->aFeatureCategory = null;
- }
- if ($this->aFeatureDesc !== null && $this->id !== $this->aFeatureDesc->getFeatureId()) {
- $this->aFeatureDesc = null;
- }
- if ($this->aFeatureProd !== null && $this->id !== $this->aFeatureProd->getFeatureId()) {
- $this->aFeatureProd = null;
- }
} // ensureConsistency
/**
@@ -491,10 +493,14 @@ abstract class BaseFeature extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aFeatureAv = null;
- $this->aFeatureCategory = null;
- $this->aFeatureDesc = null;
- $this->aFeatureProd = null;
+ $this->collFeatureAvs = null;
+
+ $this->collFeatureCategorys = null;
+
+ $this->collFeatureDescs = null;
+
+ $this->collFeatureProds = null;
+
} // if (deep)
}
@@ -608,39 +614,6 @@ abstract class BaseFeature extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // 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);
- }
- $this->setFeatureAv($this->aFeatureAv);
- }
-
- if ($this->aFeatureCategory !== null) {
- if ($this->aFeatureCategory->isModified() || $this->aFeatureCategory->isNew()) {
- $affectedRows += $this->aFeatureCategory->save($con);
- }
- $this->setFeatureCategory($this->aFeatureCategory);
- }
-
- if ($this->aFeatureDesc !== null) {
- if ($this->aFeatureDesc->isModified() || $this->aFeatureDesc->isNew()) {
- $affectedRows += $this->aFeatureDesc->save($con);
- }
- $this->setFeatureDesc($this->aFeatureDesc);
- }
-
- if ($this->aFeatureProd !== null) {
- if ($this->aFeatureProd->isModified() || $this->aFeatureProd->isNew()) {
- $affectedRows += $this->aFeatureProd->save($con);
- }
- $this->setFeatureProd($this->aFeatureProd);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -652,6 +625,74 @@ 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()
+ ->filterByPrimaryKeys($this->featureDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureDescs !== null) {
+ foreach ($this->collFeatureDescs 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);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -813,41 +854,43 @@ abstract class BaseFeature extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // 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->aFeatureCategory !== null) {
- if (!$this->aFeatureCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aFeatureCategory->getValidationFailures());
- }
- }
-
- if ($this->aFeatureDesc !== null) {
- if (!$this->aFeatureDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aFeatureDesc->getValidationFailures());
- }
- }
-
- if ($this->aFeatureProd !== null) {
- if (!$this->aFeatureProd->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aFeatureProd->getValidationFailures());
- }
- }
-
-
if (($retval = FeaturePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ 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)) {
+ $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());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -934,17 +977,17 @@ abstract class BaseFeature extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aFeatureAv) {
- $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFeatureAvs) {
+ $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aFeatureCategory) {
- $result['FeatureCategory'] = $this->aFeatureCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFeatureCategorys) {
+ $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aFeatureDesc) {
- $result['FeatureDesc'] = $this->aFeatureDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFeatureDescs) {
+ $result['FeatureDescs'] = $this->collFeatureDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aFeatureProd) {
- $result['FeatureProd'] = $this->aFeatureProd->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1115,24 +1158,28 @@ abstract class BaseFeature extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getFeatureAv();
- if ($relObj) {
- $copyObj->setFeatureAv($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));
+ }
}
- $relObj = $this->getFeatureCategory();
- if ($relObj) {
- $copyObj->setFeatureCategory($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));
+ }
}
- $relObj = $this->getFeatureDesc();
- if ($relObj) {
- $copyObj->setFeatureDesc($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));
+ }
}
- $relObj = $this->getFeatureProd();
- if ($relObj) {
- $copyObj->setFeatureProd($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));
+ }
}
//unflag object copy
@@ -1185,192 +1232,932 @@ abstract class BaseFeature extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a FeatureAv object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param FeatureAv $v
- * @return Feature The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('FeatureAv' == $relationName) {
+ $this->initFeatureAvs();
+ }
+ if ('FeatureCategory' == $relationName) {
+ $this->initFeatureCategorys();
+ }
+ if ('FeatureDesc' == $relationName) {
+ $this->initFeatureDescs();
+ }
+ if ('FeatureProd' == $relationName) {
+ $this->initFeatureProds();
+ }
+ }
+
+ /**
+ * Clears out the collFeatureAvs 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 addFeatureAvs()
+ */
+ public function clearFeatureAvs()
+ {
+ $this->collFeatureAvs = null; // important to set this to null since that means it is uninitialized
+ $this->collFeatureAvsPartial = null;
+ }
+
+ /**
+ * reset is the collFeatureAvs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialFeatureAvs($v = true)
+ {
+ $this->collFeatureAvsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureAvs collection.
+ *
+ * By default this just sets the collFeatureAvs collection to an empty array (like clearcollFeatureAvs());
+ * 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 initFeatureAvs($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureAvs && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureAvs = new PropelObjectCollection();
+ $this->collFeatureAvs->setModel('FeatureAv');
+ }
+
+ /**
+ * Gets an array of FeatureAv 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|FeatureAv[] List of FeatureAv objects
* @throws PropelException
*/
- public function setFeatureAv(FeatureAv $v = null)
+ public function getFeatureAvs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collFeatureAvsPartial && !$this->isNew();
+ if (null === $this->collFeatureAvs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureAvs) {
+ // return empty collection
+ $this->initFeatureAvs();
+ } else {
+ $collFeatureAvs = FeatureAvQuery::create(null, $criteria)
+ ->filterByFeature($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureAvsPartial && count($collFeatureAvs)) {
+ $this->initFeatureAvs(false);
+
+ foreach($collFeatureAvs as $obj) {
+ if (false == $this->collFeatureAvs->contains($obj)) {
+ $this->collFeatureAvs->append($obj);
+ }
+ }
+
+ $this->collFeatureAvsPartial = true;
+ }
+
+ return $collFeatureAvs;
+ }
+
+ if($partial && $this->collFeatureAvs) {
+ foreach($this->collFeatureAvs as $obj) {
+ if($obj->isNew()) {
+ $collFeatureAvs[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureAvs = $collFeatureAvs;
+ $this->collFeatureAvsPartial = false;
+ }
+ }
+
+ return $this->collFeatureAvs;
+ }
+
+ /**
+ * Sets a collection of FeatureAv 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 $featureAvs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setFeatureAvs(PropelCollection $featureAvs, PropelPDO $con = null)
+ {
+ $this->featureAvsScheduledForDeletion = $this->getFeatureAvs(new Criteria(), $con)->diff($featureAvs);
+
+ foreach ($this->featureAvsScheduledForDeletion as $featureAvRemoved) {
+ $featureAvRemoved->setFeature(null);
+ }
+
+ $this->collFeatureAvs = null;
+ foreach ($featureAvs as $featureAv) {
+ $this->addFeatureAv($featureAv);
+ }
+
+ $this->collFeatureAvs = $featureAvs;
+ $this->collFeatureAvsPartial = false;
+ }
+
+ /**
+ * Returns the number of related FeatureAv objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related FeatureAv objects.
+ * @throws PropelException
+ */
+ public function countFeatureAvs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collFeatureAvsPartial && !$this->isNew();
+ if (null === $this->collFeatureAvs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureAvs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getFeatureAvs());
+ }
+ $query = FeatureAvQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeature($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getFeatureId());
+ return count($this->collFeatureAvs);
}
+ }
- $this->aFeatureAv = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFeature($this);
+ /**
+ * Method called to associate a FeatureAv object to this object
+ * through the FeatureAv foreign key attribute.
+ *
+ * @param FeatureAv $l FeatureAv
+ * @return Feature The current object (for fluent API support)
+ */
+ public function addFeatureAv(FeatureAv $l)
+ {
+ if ($this->collFeatureAvs === null) {
+ $this->initFeatureAvs();
+ $this->collFeatureAvsPartial = true;
+ }
+ if (!$this->collFeatureAvs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureAv($l);
}
-
return $this;
}
-
/**
- * Get the associated FeatureAv object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return FeatureAv The associated FeatureAv object.
- * @throws PropelException
+ * @param FeatureAv $featureAv The featureAv object to add.
*/
- public function getFeatureAv(PropelPDO $con = null)
+ protected function doAddFeatureAv($featureAv)
{
- if ($this->aFeatureAv === null && ($this->id !== null)) {
- $this->aFeatureAv = FeatureAvQuery::create()
- ->filterByFeature($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFeatureAv->setFeature($this);
- }
-
- return $this->aFeatureAv;
+ $this->collFeatureAvs[]= $featureAv;
+ $featureAv->setFeature($this);
}
/**
- * Declares an association between this object and a FeatureCategory object.
+ * @param FeatureAv $featureAv The featureAv object to remove.
+ */
+ public function removeFeatureAv($featureAv)
+ {
+ if ($this->getFeatureAvs()->contains($featureAv)) {
+ $this->collFeatureAvs->remove($this->collFeatureAvs->search($featureAv));
+ if (null === $this->featureAvsScheduledForDeletion) {
+ $this->featureAvsScheduledForDeletion = clone $this->collFeatureAvs;
+ $this->featureAvsScheduledForDeletion->clear();
+ }
+ $this->featureAvsScheduledForDeletion[]= $featureAv;
+ $featureAv->setFeature(null);
+ }
+ }
+
+ /**
+ * Clears out the collFeatureCategorys collection
*
- * @param FeatureCategory $v
- * @return Feature The current object (for fluent API support)
+ * 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 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|FeatureCategory[] List of FeatureCategory objects
* @throws PropelException
*/
- public function setFeatureCategory(FeatureCategory $v = null)
+ public function getFeatureCategorys($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByFeature($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->setFeature(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
+ ->filterByFeature($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getFeatureId());
+ return count($this->collFeatureCategorys);
}
+ }
- $this->aFeatureCategory = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFeature($this);
+ /**
+ * Method called to associate a FeatureCategory object to this object
+ * through the FeatureCategory foreign key attribute.
+ *
+ * @param FeatureCategory $l FeatureCategory
+ * @return Feature 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;
}
-
/**
- * Get the associated FeatureCategory object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return FeatureCategory The associated FeatureCategory object.
- * @throws PropelException
+ * @param FeatureCategory $featureCategory The featureCategory object to add.
*/
- public function getFeatureCategory(PropelPDO $con = null)
+ protected function doAddFeatureCategory($featureCategory)
{
- if ($this->aFeatureCategory === null && ($this->id !== null)) {
- $this->aFeatureCategory = FeatureCategoryQuery::create()
- ->filterByFeature($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFeatureCategory->setFeature($this);
- }
-
- return $this->aFeatureCategory;
+ $this->collFeatureCategorys[]= $featureCategory;
+ $featureCategory->setFeature($this);
}
/**
- * Declares an association between this object and a FeatureDesc object.
+ * @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->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 FeatureCategorys from storage.
*
- * @param FeatureDesc $v
- * @return Feature The current object (for fluent API support)
+ * 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|FeatureCategory[] List of FeatureCategory objects
+ */
+ public function getFeatureCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = FeatureCategoryQuery::create(null, $criteria);
+ $query->joinWith('Category', $join_behavior);
+
+ 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 setFeatureDesc(FeatureDesc $v = null)
+ public function getFeatureDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getFeatureId());
+ return count($this->collFeatureDescs);
}
+ }
- $this->aFeatureDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFeature($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated FeatureDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return FeatureDesc The associated FeatureDesc object.
- * @throws PropelException
+ * @param FeatureDesc $featureDesc The featureDesc object to add.
*/
- public function getFeatureDesc(PropelPDO $con = null)
+ protected function doAddFeatureDesc($featureDesc)
{
- if ($this->aFeatureDesc === null && ($this->id !== null)) {
- $this->aFeatureDesc = FeatureDescQuery::create()
- ->filterByFeature($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFeatureDesc->setFeature($this);
- }
-
- return $this->aFeatureDesc;
+ $this->collFeatureDescs[]= $featureDesc;
+ $featureDesc->setFeature($this);
}
/**
- * Declares an association between this object and a FeatureProd object.
+ * @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
*
- * @param FeatureProd $v
- * @return Feature The current object (for fluent API support)
+ * 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 setFeatureProd(FeatureProd $v = null)
+ public function getFeatureProds($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getFeatureId());
+ return count($this->collFeatureProds);
}
+ }
- $this->aFeatureProd = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFeature($this);
+ /**
+ * 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);
+ }
/**
- * Get the associated FeatureProd object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return FeatureProd The associated FeatureProd object.
- * @throws PropelException
+ * @param FeatureProd $featureProd The featureProd object to remove.
*/
- public function getFeatureProd(PropelPDO $con = null)
+ public function removeFeatureProd($featureProd)
{
- if ($this->aFeatureProd === null && ($this->id !== null)) {
- $this->aFeatureProd = FeatureProdQuery::create()
- ->filterByFeature($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFeatureProd->setFeature($this);
+ 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);
}
+ }
- return $this->aFeatureProd;
+
+ /**
+ * 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);
}
/**
@@ -1404,12 +2191,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->collFeatureProds) {
+ foreach ($this->collFeatureProds as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aFeatureAv = null;
- $this->aFeatureCategory = null;
- $this->aFeatureDesc = null;
- $this->aFeatureProd = null;
+ 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->collFeatureProds instanceof PropelCollection) {
+ $this->collFeatureProds->clearIterator();
+ }
+ $this->collFeatureProds = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAv.php b/core/lib/Thelia/Model/om/BaseFeatureAv.php
index 179889582..1b8704563 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureAv.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureAv.php
@@ -78,19 +78,21 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var FeatureAvDesc
+ * @var Feature
*/
- protected $aFeatureAvDesc;
+ protected $aFeature;
/**
- * @var FeatureProd
+ * @var PropelObjectCollection|FeatureAvDesc[] Collection to store aggregation of FeatureAvDesc objects.
*/
- protected $aFeatureProd;
+ protected $collFeatureAvDescs;
+ protected $collFeatureAvDescsPartial;
/**
- * @var Feature one-to-one related Feature object
+ * @var PropelObjectCollection|FeatureProd[] Collection to store aggregation of FeatureProd objects.
*/
- protected $singleFeature;
+ protected $collFeatureProds;
+ protected $collFeatureProdsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -110,7 +112,13 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $featuresScheduledForDeletion = null;
+ protected $featureAvDescsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $featureProdsScheduledForDeletion = null;
/**
* Get the [id] column value.
@@ -223,14 +231,6 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureAvPeer::ID;
}
- if ($this->aFeatureAvDesc !== null && $this->aFeatureAvDesc->getFeatureAvId() !== $v) {
- $this->aFeatureAvDesc = null;
- }
-
- if ($this->aFeatureProd !== null && $this->aFeatureProd->getFeatureAvId() !== $v) {
- $this->aFeatureProd = null;
- }
-
return $this;
} // setId()
@@ -252,6 +252,10 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureAvPeer::FEATURE_ID;
}
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
return $this;
} // setFeatureId()
@@ -369,11 +373,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aFeatureAvDesc !== null && $this->id !== $this->aFeatureAvDesc->getFeatureAvId()) {
- $this->aFeatureAvDesc = null;
- }
- if ($this->aFeatureProd !== null && $this->id !== $this->aFeatureProd->getFeatureAvId()) {
- $this->aFeatureProd = null;
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
}
} // ensureConsistency
@@ -414,9 +415,10 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aFeatureAvDesc = null;
- $this->aFeatureProd = null;
- $this->singleFeature = null;
+ $this->aFeature = null;
+ $this->collFeatureAvDescs = null;
+
+ $this->collFeatureProds = null;
} // if (deep)
}
@@ -536,18 +538,11 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aFeatureAvDesc !== null) {
- if ($this->aFeatureAvDesc->isModified() || $this->aFeatureAvDesc->isNew()) {
- $affectedRows += $this->aFeatureAvDesc->save($con);
+ if ($this->aFeature !== null) {
+ if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
+ $affectedRows += $this->aFeature->save($con);
}
- $this->setFeatureAvDesc($this->aFeatureAvDesc);
- }
-
- if ($this->aFeatureProd !== null) {
- if ($this->aFeatureProd->isModified() || $this->aFeatureProd->isNew()) {
- $affectedRows += $this->aFeatureProd->save($con);
- }
- $this->setFeatureProd($this->aFeatureProd);
+ $this->setFeature($this->aFeature);
}
if ($this->isNew() || $this->isModified()) {
@@ -561,18 +556,38 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->featuresScheduledForDeletion !== null) {
- if (!$this->featuresScheduledForDeletion->isEmpty()) {
- FeatureQuery::create()
- ->filterByPrimaryKeys($this->featuresScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->featureAvDescsScheduledForDeletion !== null) {
+ if (!$this->featureAvDescsScheduledForDeletion->isEmpty()) {
+ FeatureAvDescQuery::create()
+ ->filterByPrimaryKeys($this->featureAvDescsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->featuresScheduledForDeletion = null;
+ $this->featureAvDescsScheduledForDeletion = null;
}
}
- if ($this->singleFeature !== null) {
- if (!$this->singleFeature->isDeleted()) {
- $affectedRows += $this->singleFeature->save($con);
+ if ($this->collFeatureAvDescs !== null) {
+ foreach ($this->collFeatureAvDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->featureProdsScheduledForDeletion !== null) {
+ if (!$this->featureProdsScheduledForDeletion->isEmpty()) {
+ foreach ($this->featureProdsScheduledForDeletion as $featureProd) {
+ // need to save related object because we set the relation to null
+ $featureProd->save($con);
+ }
+ $this->featureProdsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureProds !== null) {
+ foreach ($this->collFeatureProds as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
}
}
@@ -736,15 +751,9 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aFeatureAvDesc !== null) {
- if (!$this->aFeatureAvDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aFeatureAvDesc->getValidationFailures());
- }
- }
-
- if ($this->aFeatureProd !== null) {
- if (!$this->aFeatureProd->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aFeatureProd->getValidationFailures());
+ if ($this->aFeature !== null) {
+ if (!$this->aFeature->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures());
}
}
@@ -754,9 +763,19 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
}
- if ($this->singleFeature !== null) {
- if (!$this->singleFeature->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFeature->getValidationFailures());
+ if ($this->collFeatureAvDescs !== null) {
+ foreach ($this->collFeatureAvDescs 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());
+ }
}
}
@@ -842,14 +861,14 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
$keys[3] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aFeatureAvDesc) {
- $result['FeatureAvDesc'] = $this->aFeatureAvDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->aFeatureProd) {
- $result['FeatureProd'] = $this->aFeatureProd->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFeatureAvDescs) {
+ $result['FeatureAvDescs'] = $this->collFeatureAvDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->singleFeature) {
- $result['Feature'] = $this->singleFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1014,19 +1033,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getFeature();
- if ($relObj) {
- $copyObj->setFeature($relObj->copy($deepCopy));
+ foreach ($this->getFeatureAvDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureAvDesc($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getFeatureAvDesc();
- if ($relObj) {
- $copyObj->setFeatureAvDesc($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getFeatureProd();
- if ($relObj) {
- $copyObj->setFeatureProd($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));
+ }
}
//unflag object copy
@@ -1080,25 +1096,26 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a FeatureAvDesc object.
+ * Declares an association between this object and a Feature object.
*
- * @param FeatureAvDesc $v
+ * @param Feature $v
* @return FeatureAv The current object (for fluent API support)
* @throws PropelException
*/
- public function setFeatureAvDesc(FeatureAvDesc $v = null)
+ public function setFeature(Feature $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setFeatureId(NULL);
} else {
- $this->setId($v->getFeatureAvId());
+ $this->setFeatureId($v->getId());
}
- $this->aFeatureAvDesc = $v;
+ $this->aFeature = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Feature object, it will not be re-added.
if ($v !== null) {
- $v->setFeatureAv($this);
+ $v->addFeatureAv($this);
}
@@ -1107,70 +1124,26 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
/**
- * Get the associated FeatureAvDesc object
+ * Get the associated Feature object
*
* @param PropelPDO $con Optional Connection object.
- * @return FeatureAvDesc The associated FeatureAvDesc object.
+ * @return Feature The associated Feature object.
* @throws PropelException
*/
- public function getFeatureAvDesc(PropelPDO $con = null)
+ public function getFeature(PropelPDO $con = null)
{
- if ($this->aFeatureAvDesc === null && ($this->id !== null)) {
- $this->aFeatureAvDesc = FeatureAvDescQuery::create()
- ->filterByFeatureAv($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFeatureAvDesc->setFeatureAv($this);
+ if ($this->aFeature === null && ($this->feature_id !== null)) {
+ $this->aFeature = FeatureQuery::create()->findPk($this->feature_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->aFeature->addFeatureAvs($this);
+ */
}
- return $this->aFeatureAvDesc;
- }
-
- /**
- * Declares an association between this object and a FeatureProd object.
- *
- * @param FeatureProd $v
- * @return FeatureAv The current object (for fluent API support)
- * @throws PropelException
- */
- public function setFeatureProd(FeatureProd $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getFeatureAvId());
- }
-
- $this->aFeatureProd = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFeatureAv($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated FeatureProd object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return FeatureProd The associated FeatureProd object.
- * @throws PropelException
- */
- public function getFeatureProd(PropelPDO $con = null)
- {
- if ($this->aFeatureProd === null && ($this->id !== null)) {
- $this->aFeatureProd = FeatureProdQuery::create()
- ->filterByFeatureAv($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFeatureProd->setFeatureAv($this);
- }
-
- return $this->aFeatureProd;
+ return $this->aFeature;
}
@@ -1184,44 +1157,478 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ if ('FeatureAvDesc' == $relationName) {
+ $this->initFeatureAvDescs();
+ }
+ if ('FeatureProd' == $relationName) {
+ $this->initFeatureProds();
+ }
}
/**
- * Gets a single Feature object, which is related to this object by a one-to-one relationship.
+ * Clears out the collFeatureAvDescs 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 addFeatureAvDescs()
+ */
+ public function clearFeatureAvDescs()
+ {
+ $this->collFeatureAvDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collFeatureAvDescsPartial = null;
+ }
+
+ /**
+ * reset is the collFeatureAvDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialFeatureAvDescs($v = true)
+ {
+ $this->collFeatureAvDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureAvDescs collection.
+ *
+ * By default this just sets the collFeatureAvDescs collection to an empty array (like clearcollFeatureAvDescs());
+ * 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 initFeatureAvDescs($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureAvDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureAvDescs = new PropelObjectCollection();
+ $this->collFeatureAvDescs->setModel('FeatureAvDesc');
+ }
+
+ /**
+ * Gets an array of FeatureAvDesc 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 FeatureAv 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 Feature
+ * @return PropelObjectCollection|FeatureAvDesc[] List of FeatureAvDesc objects
* @throws PropelException
*/
- public function getFeature(PropelPDO $con = null)
+ public function getFeatureAvDescs($criteria = null, PropelPDO $con = null)
{
+ $partial = $this->collFeatureAvDescsPartial && !$this->isNew();
+ if (null === $this->collFeatureAvDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureAvDescs) {
+ // return empty collection
+ $this->initFeatureAvDescs();
+ } else {
+ $collFeatureAvDescs = FeatureAvDescQuery::create(null, $criteria)
+ ->filterByFeatureAv($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureAvDescsPartial && count($collFeatureAvDescs)) {
+ $this->initFeatureAvDescs(false);
- if ($this->singleFeature === null && !$this->isNew()) {
- $this->singleFeature = FeatureQuery::create()->findPk($this->getPrimaryKey(), $con);
+ foreach($collFeatureAvDescs as $obj) {
+ if (false == $this->collFeatureAvDescs->contains($obj)) {
+ $this->collFeatureAvDescs->append($obj);
+ }
+ }
+
+ $this->collFeatureAvDescsPartial = true;
+ }
+
+ return $collFeatureAvDescs;
+ }
+
+ if($partial && $this->collFeatureAvDescs) {
+ foreach($this->collFeatureAvDescs as $obj) {
+ if($obj->isNew()) {
+ $collFeatureAvDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureAvDescs = $collFeatureAvDescs;
+ $this->collFeatureAvDescsPartial = false;
+ }
}
- return $this->singleFeature;
+ return $this->collFeatureAvDescs;
}
/**
- * Sets a single Feature object as related to this object by a one-to-one relationship.
+ * Sets a collection of FeatureAvDesc 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 Feature $v Feature
- * @return FeatureAv The current object (for fluent API support)
+ * @param PropelCollection $featureAvDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setFeatureAvDescs(PropelCollection $featureAvDescs, PropelPDO $con = null)
+ {
+ $this->featureAvDescsScheduledForDeletion = $this->getFeatureAvDescs(new Criteria(), $con)->diff($featureAvDescs);
+
+ foreach ($this->featureAvDescsScheduledForDeletion as $featureAvDescRemoved) {
+ $featureAvDescRemoved->setFeatureAv(null);
+ }
+
+ $this->collFeatureAvDescs = null;
+ foreach ($featureAvDescs as $featureAvDesc) {
+ $this->addFeatureAvDesc($featureAvDesc);
+ }
+
+ $this->collFeatureAvDescs = $featureAvDescs;
+ $this->collFeatureAvDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related FeatureAvDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related FeatureAvDesc objects.
* @throws PropelException
*/
- public function setFeature(Feature $v = null)
+ public function countFeatureAvDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleFeature = $v;
+ $partial = $this->collFeatureAvDescsPartial && !$this->isNew();
+ if (null === $this->collFeatureAvDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureAvDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getFeatureAvDescs());
+ }
+ $query = FeatureAvDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
- // Make sure that that the passed-in Feature isn't already associated with this object
- if ($v !== null && $v->getFeatureAv() === null) {
- $v->setFeatureAv($this);
+ return $query
+ ->filterByFeatureAv($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collFeatureAvDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a FeatureAvDesc object to this object
+ * through the FeatureAvDesc foreign key attribute.
+ *
+ * @param FeatureAvDesc $l FeatureAvDesc
+ * @return FeatureAv The current object (for fluent API support)
+ */
+ public function addFeatureAvDesc(FeatureAvDesc $l)
+ {
+ if ($this->collFeatureAvDescs === null) {
+ $this->initFeatureAvDescs();
+ $this->collFeatureAvDescsPartial = true;
+ }
+ if (!$this->collFeatureAvDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureAvDesc($l);
}
return $this;
}
+ /**
+ * @param FeatureAvDesc $featureAvDesc The featureAvDesc object to add.
+ */
+ protected function doAddFeatureAvDesc($featureAvDesc)
+ {
+ $this->collFeatureAvDescs[]= $featureAvDesc;
+ $featureAvDesc->setFeatureAv($this);
+ }
+
+ /**
+ * @param FeatureAvDesc $featureAvDesc The featureAvDesc object to remove.
+ */
+ public function removeFeatureAvDesc($featureAvDesc)
+ {
+ if ($this->getFeatureAvDescs()->contains($featureAvDesc)) {
+ $this->collFeatureAvDescs->remove($this->collFeatureAvDescs->search($featureAvDesc));
+ if (null === $this->featureAvDescsScheduledForDeletion) {
+ $this->featureAvDescsScheduledForDeletion = clone $this->collFeatureAvDescs;
+ $this->featureAvDescsScheduledForDeletion->clear();
+ }
+ $this->featureAvDescsScheduledForDeletion[]= $featureAvDesc;
+ $featureAvDesc->setFeatureAv(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 FeatureAv 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)
+ ->filterByFeatureAv($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->setFeatureAv(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
+ ->filterByFeatureAv($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 FeatureAv 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->setFeatureAv($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->setFeatureAv(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this FeatureAv is new, it will return
+ * an empty collection; or if this FeatureAv 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 FeatureAv.
+ *
+ * @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 FeatureAv is new, it will return
+ * an empty collection; or if this FeatureAv 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 FeatureAv.
+ *
+ * @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
*/
@@ -1251,17 +1658,27 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleFeature) {
- $this->singleFeature->clearAllReferences($deep);
+ if ($this->collFeatureAvDescs) {
+ foreach ($this->collFeatureAvDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatureProds) {
+ foreach ($this->collFeatureProds as $o) {
+ $o->clearAllReferences($deep);
+ }
}
} // if ($deep)
- if ($this->singleFeature instanceof PropelCollection) {
- $this->singleFeature->clearIterator();
+ if ($this->collFeatureAvDescs instanceof PropelCollection) {
+ $this->collFeatureAvDescs->clearIterator();
}
- $this->singleFeature = null;
- $this->aFeatureAvDesc = null;
- $this->aFeatureProd = null;
+ $this->collFeatureAvDescs = null;
+ if ($this->collFeatureProds instanceof PropelCollection) {
+ $this->collFeatureProds->clearIterator();
+ }
+ $this->collFeatureProds = null;
+ $this->aFeature = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php b/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php
index 226ce741f..d01569462 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php
@@ -9,9 +9,7 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\FeatureAv;
use Thelia\Model\FeatureAvDesc;
@@ -84,9 +82,9 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
protected $chapo;
/**
- * @var FeatureAv one-to-one related FeatureAv object
+ * @var FeatureAv
*/
- protected $singleFeatureAv;
+ protected $aFeatureAv;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -102,12 +100,6 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $featureAvsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -206,6 +198,10 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureAvDescPeer::FEATURE_AV_ID;
}
+ if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) {
+ $this->aFeatureAv = null;
+ }
+
return $this;
} // setFeatureAvId()
@@ -363,6 +359,9 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aFeatureAv !== null && $this->feature_av_id !== $this->aFeatureAv->getId()) {
+ $this->aFeatureAv = null;
+ }
} // ensureConsistency
/**
@@ -402,8 +401,7 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleFeatureAv = null;
-
+ $this->aFeatureAv = null;
} // if (deep)
}
@@ -517,6 +515,18 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // 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);
+ }
+ $this->setFeatureAv($this->aFeatureAv);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -528,21 +538,6 @@ abstract class BaseFeatureAvDesc 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->singleFeatureAv !== null) {
- if (!$this->singleFeatureAv->isDeleted()) {
- $affectedRows += $this->singleFeatureAv->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -710,17 +705,23 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // 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 (($retval = FeatureAvDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleFeatureAv !== null) {
- if (!$this->singleFeatureAv->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFeatureAv->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -811,8 +812,8 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
$keys[5] => $this->getChapo(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleFeatureAv) {
- $result['FeatureAv'] = $this->singleFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFeatureAv) {
+ $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -989,11 +990,6 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getFeatureAv();
- if ($relObj) {
- $copyObj->setFeatureAv($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1044,55 +1040,57 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a FeatureAv object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single FeatureAv object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return FeatureAv
- * @throws PropelException
- */
- public function getFeatureAv(PropelPDO $con = null)
- {
-
- if ($this->singleFeatureAv === null && !$this->isNew()) {
- $this->singleFeatureAv = FeatureAvQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleFeatureAv;
- }
-
- /**
- * Sets a single FeatureAv object as related to this object by a one-to-one relationship.
- *
- * @param FeatureAv $v FeatureAv
+ * @param FeatureAv $v
* @return FeatureAvDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setFeatureAv(FeatureAv $v = null)
{
- $this->singleFeatureAv = $v;
-
- // Make sure that that the passed-in FeatureAv isn't already associated with this object
- if ($v !== null && $v->getFeatureAvDesc() === null) {
- $v->setFeatureAvDesc($this);
+ if ($v === null) {
+ $this->setFeatureAvId(NULL);
+ } else {
+ $this->setFeatureAvId($v->getId());
}
+ $this->aFeatureAv = $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 ($v !== null) {
+ $v->addFeatureAvDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated FeatureAv object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return FeatureAv The associated FeatureAv object.
+ * @throws PropelException
+ */
+ public function getFeatureAv(PropelPDO $con = null)
+ {
+ 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->aFeatureAv->addFeatureAvDescs($this);
+ */
+ }
+
+ return $this->aFeatureAv;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1124,15 +1122,9 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleFeatureAv) {
- $this->singleFeatureAv->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleFeatureAv instanceof PropelCollection) {
- $this->singleFeatureAv->clearIterator();
- }
- $this->singleFeatureAv = null;
+ $this->aFeatureAv = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php
index 247fc676d..6799cdd18 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseFeatureAvDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'feature_av_desc';
@@ -388,9 +388,6 @@ abstract class BaseFeatureAvDescPeer
*/
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();
}
/**
@@ -487,6 +484,244 @@ abstract class BaseFeatureAvDescPeer
return array($obj, $col);
}
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureAvDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureAvDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureAvDescPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of FeatureAvDesc 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
+ * @return array Array of FeatureAvDesc objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME);
+ }
+
+ FeatureAvDescPeer::addSelectColumns($criteria);
+ $startcol = FeatureAvDescPeer::NUM_HYDRATE_COLUMNS;
+ FeatureAvPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FeatureAvDescPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureAvDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureAvDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FeatureAvDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureAvDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeatureAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FeatureAvPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (FeatureAvDesc) to $obj2 (FeatureAv)
+ $obj2->addFeatureAvDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureAvDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureAvDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureAvDescPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of FeatureAvDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureAvDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME);
+ }
+
+ FeatureAvDescPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureAvDescPeer::NUM_HYDRATE_COLUMNS;
+
+ FeatureAvPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FeatureAvDescPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureAvDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureAvDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureAvDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureAvDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined FeatureAv rows
+
+ $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeatureAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FeatureAvPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (FeatureAvDesc) to the collection in $obj2 (FeatureAv)
+ $obj2->addFeatureAvDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -620,7 +855,6 @@ abstract class BaseFeatureAvDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += FeatureAvDescPeer::doOnDeleteCascade(new Criteria(FeatureAvDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(FeatureAvDescPeer::TABLE_NAME, $con, FeatureAvDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -654,14 +888,24 @@ abstract class BaseFeatureAvDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ FeatureAvDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof FeatureAvDesc) { // it's a model object
+ // invalidate the cache for this single object
+ FeatureAvDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(FeatureAvDescPeer::DATABASE_NAME);
$criteria->add(FeatureAvDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ FeatureAvDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -674,23 +918,6 @@ abstract class BaseFeatureAvDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += FeatureAvDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- FeatureAvDescPeer::clearInstancePool();
- } elseif ($values instanceof FeatureAvDesc) { // it's a model object
- FeatureAvDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- FeatureAvDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
FeatureAvDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -702,39 +929,6 @@ abstract class BaseFeatureAvDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = FeatureAvDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related FeatureAv objects
- $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
-
- $criteria->add(FeatureAvPeer::ID, $obj->getFeatureAvId());
- $affectedRows += FeatureAvPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given FeatureAvDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php
index bad19a06e..001058925 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php
@@ -72,7 +72,7 @@ abstract class BaseFeatureAvDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\FeatureAvDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\FeatureAvDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -275,6 +275,8 @@ abstract class BaseFeatureAvDescQuery extends ModelCriteria
* $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id > 12
*
*
+ * @see filterByFeatureAv()
+ *
* @param mixed $featureAvId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -425,7 +427,7 @@ abstract class BaseFeatureAvDescQuery extends ModelCriteria
/**
* Filter the query by a related FeatureAv object
*
- * @param FeatureAv|PropelObjectCollection $featureAv the related object 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 FeatureAvDescQuery The current query, for fluid interface
@@ -437,10 +439,12 @@ abstract class BaseFeatureAvDescQuery extends ModelCriteria
return $this
->addUsingAlias(FeatureAvDescPeer::FEATURE_AV_ID, $featureAv->getId(), $comparison);
} elseif ($featureAv instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useFeatureAvQuery()
- ->filterByPrimaryKeys($featureAv->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(FeatureAvDescPeer::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php
index c8d93f953..e8e9232dd 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php
@@ -27,7 +27,7 @@ abstract class BaseFeatureAvPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'feature_av';
@@ -380,9 +380,12 @@ abstract class BaseFeatureAvPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in FeaturePeer instance pool,
+ // Invalidate objects in FeatureAvDescPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FeaturePeer::clearInstancePool();
+ FeatureAvDescPeer::clearInstancePool();
+ // Invalidate objects in FeatureProdPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ FeatureProdPeer::clearInstancePool();
}
/**
@@ -481,7 +484,7 @@ abstract class BaseFeatureAvPeer
/**
- * Returns the number of rows matching criteria, joining the related FeatureAvDesc table
+ * Returns the number of rows matching criteria, joining the related Feature table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -489,7 +492,7 @@ abstract class BaseFeatureAvPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinFeatureAvDesc(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinFeature(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;
@@ -516,7 +519,7 @@ abstract class BaseFeatureAvPeer
$con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(FeatureAvPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, $join_behavior);
+ $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -532,58 +535,7 @@ abstract class BaseFeatureAvPeer
/**
- * Returns the number of rows matching criteria, joining the related FeatureProd table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinFeatureProd(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeatureAvPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeatureAvPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureProdPeer::FEATURE_AV_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of FeatureAv objects pre-filled with their FeatureAvDesc objects.
+ * Selects a collection of FeatureAv objects pre-filled with their Feature objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -591,7 +543,7 @@ abstract class BaseFeatureAvPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinFeatureAvDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -602,9 +554,9 @@ abstract class BaseFeatureAvPeer
FeatureAvPeer::addSelectColumns($criteria);
$startcol = FeatureAvPeer::NUM_HYDRATE_COLUMNS;
- FeatureAvDescPeer::addSelectColumns($criteria);
+ FeaturePeer::addSelectColumns($criteria);
- $criteria->addJoin(FeatureAvPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, $join_behavior);
+ $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -624,89 +576,20 @@ abstract class BaseFeatureAvPeer
FeatureAvPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = FeatureAvDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = FeatureAvDescPeer::getInstanceFromPool($key2);
+ $obj2 = FeaturePeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = FeatureAvDescPeer::getOMClass();
+ $cls = FeaturePeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- FeatureAvDescPeer::addInstanceToPool($obj2, $key2);
+ FeaturePeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (FeatureAv) to $obj2 (FeatureAvDesc)
- // one to one relationship
- $obj1->setFeatureAvDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of FeatureAv objects pre-filled with their FeatureProd objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of FeatureAv objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinFeatureProd(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
- }
-
- FeatureAvPeer::addSelectColumns($criteria);
- $startcol = FeatureAvPeer::NUM_HYDRATE_COLUMNS;
- FeatureProdPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureProdPeer::FEATURE_AV_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeatureAvPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FeatureAvPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeatureAvPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = FeatureProdPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- FeatureProdPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (FeatureAv) to $obj2 (FeatureProd)
- // one to one relationship
- $obj1->setFeatureProd($obj2);
+ // Add the $obj1 (FeatureAv) to $obj2 (Feature)
+ $obj2->addFeatureAv($obj1);
} // if joined row was not null
@@ -754,9 +637,7 @@ abstract class BaseFeatureAvPeer
$con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(FeatureAvPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, $join_behavior);
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureProdPeer::FEATURE_AV_ID, $join_behavior);
+ $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -792,15 +673,10 @@ abstract class BaseFeatureAvPeer
FeatureAvPeer::addSelectColumns($criteria);
$startcol2 = FeatureAvPeer::NUM_HYDRATE_COLUMNS;
- FeatureAvDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + FeatureAvDescPeer::NUM_HYDRATE_COLUMNS;
+ FeaturePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS;
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, $join_behavior);
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureProdPeer::FEATURE_AV_ID, $join_behavior);
+ $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -819,292 +695,24 @@ abstract class BaseFeatureAvPeer
FeatureAvPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined FeatureAvDesc rows
+ // Add objects for joined Feature rows
- $key2 = FeatureAvDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = FeatureAvDescPeer::getInstanceFromPool($key2);
+ $obj2 = FeaturePeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = FeatureAvDescPeer::getOMClass();
+ $cls = FeaturePeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- FeatureAvDescPeer::addInstanceToPool($obj2, $key2);
+ FeaturePeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (FeatureAv) to the collection in $obj2 (FeatureAvDesc)
- $obj1->setFeatureAvDesc($obj2);
+ // Add the $obj1 (FeatureAv) to the collection in $obj2 (Feature)
+ $obj2->addFeatureAv($obj1);
} // if joined row not null
- // Add objects for joined FeatureProd rows
-
- $key3 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = FeatureProdPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- FeatureProdPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (FeatureAv) to the collection in $obj3 (FeatureProd)
- $obj1->setFeatureProd($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureAvDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptFeatureAvDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeatureAvPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeatureAvPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureProdPeer::FEATURE_AV_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureProd table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptFeatureProd(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeatureAvPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeatureAvPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of FeatureAv objects pre-filled with all related objects except FeatureAvDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of FeatureAv objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptFeatureAvDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
- }
-
- FeatureAvPeer::addSelectColumns($criteria);
- $startcol2 = FeatureAvPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureProdPeer::FEATURE_AV_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeatureAvPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FeatureAvPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeatureAvPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined FeatureProd rows
-
- $key2 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = FeatureProdPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- FeatureProdPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (FeatureAv) to the collection in $obj2 (FeatureProd)
- $obj1->setFeatureProd($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of FeatureAv objects pre-filled with all related objects except FeatureProd.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of FeatureAv objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptFeatureProd(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
- }
-
- FeatureAvPeer::addSelectColumns($criteria);
- $startcol2 = FeatureAvPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureAvDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + FeatureAvDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FeatureAvPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeatureAvPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FeatureAvPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeatureAvPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined FeatureAvDesc rows
-
- $key2 = FeatureAvDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = FeatureAvDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureAvDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- FeatureAvDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (FeatureAv) to the collection in $obj2 (FeatureAvDesc)
- $obj1->setFeatureAvDesc($obj2);
-
- } // if joined row is not null
-
$results[] = $obj1;
}
$stmt->closeCursor();
@@ -1245,7 +853,6 @@ abstract class BaseFeatureAvPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += FeatureAvPeer::doOnDeleteCascade(new Criteria(FeatureAvPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(FeatureAvPeer::TABLE_NAME, $con, FeatureAvPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -1279,14 +886,24 @@ abstract class BaseFeatureAvPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ FeatureAvPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof FeatureAv) { // it's a model object
+ // invalidate the cache for this single object
+ FeatureAvPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
$criteria->add(FeatureAvPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ FeatureAvPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -1299,23 +916,6 @@ abstract class BaseFeatureAvPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += FeatureAvPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- FeatureAvPeer::clearInstancePool();
- } elseif ($values instanceof FeatureAv) { // it's a model object
- FeatureAvPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- FeatureAvPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
FeatureAvPeer::clearRelatedInstancePool();
$con->commit();
@@ -1327,39 +927,6 @@ abstract class BaseFeatureAvPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = FeatureAvPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Feature objects
- $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
-
- $criteria->add(FeaturePeer::ID, $obj->getFeatureId());
- $affectedRows += FeaturePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given FeatureAv object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php
index d1a2d2bd0..56948a5d2 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php
@@ -38,6 +38,10 @@ use Thelia\Model\FeatureProd;
* @method FeatureAvQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method FeatureAvQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
+ * @method FeatureAvQuery leftJoinFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the Feature relation
+ * @method FeatureAvQuery rightJoinFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Feature relation
+ * @method FeatureAvQuery innerJoinFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the Feature relation
+ *
* @method FeatureAvQuery leftJoinFeatureAvDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureAvDesc relation
* @method FeatureAvQuery rightJoinFeatureAvDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureAvDesc relation
* @method FeatureAvQuery innerJoinFeatureAvDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureAvDesc relation
@@ -46,10 +50,6 @@ use Thelia\Model\FeatureProd;
* @method FeatureAvQuery rightJoinFeatureProd($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureProd relation
* @method FeatureAvQuery innerJoinFeatureProd($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureProd relation
*
- * @method FeatureAvQuery leftJoinFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the Feature relation
- * @method FeatureAvQuery rightJoinFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Feature relation
- * @method FeatureAvQuery innerJoinFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the Feature relation
- *
* @method FeatureAv findOne(PropelPDO $con = null) Return the first FeatureAv matching the query
* @method FeatureAv findOneOrCreate(PropelPDO $con = null) Return the first FeatureAv matching the query, or a new FeatureAv object populated from the query conditions when no match is found
*
@@ -74,7 +74,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\FeatureAv', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\FeatureAv', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -250,10 +250,6 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByFeatureAvDesc()
- *
- * @see filterByFeatureProd()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -281,6 +277,8 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
* $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
*
*
+ * @see filterByFeature()
+ *
* @param mixed $featureId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -398,10 +396,86 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
return $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query by a related Feature object
+ *
+ * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFeature($feature, $comparison = null)
+ {
+ if ($feature instanceof Feature) {
+ return $this
+ ->addUsingAlias(FeatureAvPeer::FEATURE_ID, $feature->getId(), $comparison);
+ } elseif ($feature instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureAvPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Feature relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Feature');
+
+ // 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, 'Feature');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Feature relation Feature 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\FeatureQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeature($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery');
+ }
+
/**
* Filter the query by a related FeatureAvDesc object
*
- * @param FeatureAvDesc|PropelObjectCollection $featureAvDesc The related object(s) to use as filter
+ * @param FeatureAvDesc|PropelObjectCollection $featureAvDesc the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FeatureAvQuery The current query, for fluid interface
@@ -413,12 +487,10 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
return $this
->addUsingAlias(FeatureAvPeer::ID, $featureAvDesc->getFeatureAvId(), $comparison);
} elseif ($featureAvDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FeatureAvPeer::ID, $featureAvDesc->toKeyValue('PrimaryKey', 'FeatureAvId'), $comparison);
+ ->useFeatureAvDescQuery()
+ ->filterByPrimaryKeys($featureAvDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFeatureAvDesc() only accepts arguments of type FeatureAvDesc or PropelCollection');
}
@@ -477,7 +549,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
/**
* Filter the query by a related FeatureProd object
*
- * @param FeatureProd|PropelObjectCollection $featureProd The related object(s) to use as filter
+ * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FeatureAvQuery The current query, for fluid interface
@@ -489,12 +561,10 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
return $this
->addUsingAlias(FeatureAvPeer::ID, $featureProd->getFeatureAvId(), $comparison);
} elseif ($featureProd instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FeatureAvPeer::ID, $featureProd->toKeyValue('PrimaryKey', 'FeatureAvId'), $comparison);
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection');
}
@@ -508,7 +578,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
*
* @return FeatureAvQuery The current query, for fluid interface
*/
- public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('FeatureProd');
@@ -543,87 +613,13 @@ abstract class BaseFeatureAvQuery extends ModelCriteria
*
* @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query
*/
- public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinFeatureProd($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery');
}
- /**
- * Filter the query by a related Feature object
- *
- * @param Feature|PropelObjectCollection $feature the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return FeatureAvQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByFeature($feature, $comparison = null)
- {
- if ($feature instanceof Feature) {
- return $this
- ->addUsingAlias(FeatureAvPeer::FEATURE_ID, $feature->getId(), $comparison);
- } elseif ($feature instanceof PropelObjectCollection) {
- return $this
- ->useFeatureQuery()
- ->filterByPrimaryKeys($feature->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Feature relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return FeatureAvQuery The current query, for fluid interface
- */
- public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Feature');
-
- // 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, 'Feature');
- }
-
- return $this;
- }
-
- /**
- * Use the Feature relation Feature 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\FeatureQuery A secondary query class using the current class as primary query
- */
- public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinFeature($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery');
- }
-
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategory.php b/core/lib/Thelia/Model/om/BaseFeatureCategory.php
index 4524ca898..098fe90cb 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureCategory.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureCategory.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Category;
use Thelia\Model\CategoryQuery;
@@ -82,14 +80,14 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Category one-to-one related Category object
+ * @var Category
*/
- protected $singleCategory;
+ protected $aCategory;
/**
- * @var Feature one-to-one related Feature object
+ * @var Feature
*/
- protected $singleFeature;
+ protected $aFeature;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -105,18 +103,6 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $categorysScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $featuresScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -259,6 +245,10 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureCategoryPeer::FEATURE_ID;
}
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
return $this;
} // setFeatureId()
@@ -280,6 +270,10 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureCategoryPeer::CATEGORY_ID;
}
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
return $this;
} // setCategoryId()
@@ -398,6 +392,12 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
} // ensureConsistency
/**
@@ -437,10 +437,8 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCategory = null;
-
- $this->singleFeature = null;
-
+ $this->aCategory = null;
+ $this->aFeature = null;
} // if (deep)
}
@@ -554,6 +552,25 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aFeature !== null) {
+ if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
+ $affectedRows += $this->aFeature->save($con);
+ }
+ $this->setFeature($this->aFeature);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -565,36 +582,6 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->categorysScheduledForDeletion !== null) {
- if (!$this->categorysScheduledForDeletion->isEmpty()) {
- CategoryQuery::create()
- ->filterByPrimaryKeys($this->categorysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->categorysScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->isDeleted()) {
- $affectedRows += $this->singleCategory->save($con);
- }
- }
-
- if ($this->featuresScheduledForDeletion !== null) {
- if (!$this->featuresScheduledForDeletion->isEmpty()) {
- FeatureQuery::create()
- ->filterByPrimaryKeys($this->featuresScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->featuresScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFeature !== null) {
- if (!$this->singleFeature->isDeleted()) {
- $affectedRows += $this->singleFeature->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -756,23 +743,29 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+ if ($this->aFeature !== null) {
+ if (!$this->aFeature->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures());
+ }
+ }
+
+
if (($retval = FeatureCategoryPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCategory->getValidationFailures());
- }
- }
-
- if ($this->singleFeature !== null) {
- if (!$this->singleFeature->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFeature->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -859,11 +852,11 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCategory) {
- $result['Category'] = $this->singleCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleFeature) {
- $result['Feature'] = $this->singleFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1034,16 +1027,6 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCategory();
- if ($relObj) {
- $copyObj->setCategory($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getFeature();
- if ($relObj) {
- $copyObj->setFeature($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1094,91 +1077,108 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Category object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Category object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Category
- * @throws PropelException
- */
- public function getCategory(PropelPDO $con = null)
- {
-
- if ($this->singleCategory === null && !$this->isNew()) {
- $this->singleCategory = CategoryQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCategory;
- }
-
- /**
- * Sets a single Category object as related to this object by a one-to-one relationship.
- *
- * @param Category $v Category
+ * @param Category $v
* @return FeatureCategory The current object (for fluent API support)
* @throws PropelException
*/
public function setCategory(Category $v = null)
{
- $this->singleCategory = $v;
-
- // Make sure that that the passed-in Category isn't already associated with this object
- if ($v !== null && $v->getFeatureCategory() === null) {
- $v->setFeatureCategory($this);
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
}
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Category object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureCategory($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Feature object, which is related to this object by a one-to-one relationship.
+ * Get the associated Category object
*
- * @param PropelPDO $con optional connection object
- * @return Feature
+ * @param PropelPDO $con Optional Connection object.
+ * @return Category The associated Category object.
* @throws PropelException
*/
- public function getFeature(PropelPDO $con = null)
+ public function getCategory(PropelPDO $con = null)
{
-
- if ($this->singleFeature === null && !$this->isNew()) {
- $this->singleFeature = FeatureQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->category_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->aCategory->addFeatureCategorys($this);
+ */
}
- return $this->singleFeature;
+ return $this->aCategory;
}
/**
- * Sets a single Feature object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Feature object.
*
- * @param Feature $v Feature
+ * @param Feature $v
* @return FeatureCategory The current object (for fluent API support)
* @throws PropelException
*/
public function setFeature(Feature $v = null)
{
- $this->singleFeature = $v;
-
- // Make sure that that the passed-in Feature isn't already associated with this object
- if ($v !== null && $v->getFeatureCategory() === null) {
- $v->setFeatureCategory($this);
+ if ($v === null) {
+ $this->setFeatureId(NULL);
+ } else {
+ $this->setFeatureId($v->getId());
}
+ $this->aFeature = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Feature object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureCategory($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Feature object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Feature The associated Feature object.
+ * @throws PropelException
+ */
+ public function getFeature(PropelPDO $con = null)
+ {
+ if ($this->aFeature === null && ($this->feature_id !== null)) {
+ $this->aFeature = FeatureQuery::create()->findPk($this->feature_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->aFeature->addFeatureCategorys($this);
+ */
+ }
+
+ return $this->aFeature;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1209,22 +1209,10 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCategory) {
- $this->singleCategory->clearAllReferences($deep);
- }
- if ($this->singleFeature) {
- $this->singleFeature->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCategory instanceof PropelCollection) {
- $this->singleCategory->clearIterator();
- }
- $this->singleCategory = null;
- if ($this->singleFeature instanceof PropelCollection) {
- $this->singleFeature->clearIterator();
- }
- $this->singleFeature = null;
+ $this->aCategory = null;
+ $this->aFeature = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php
index 88aa307f8..bbd78d2a6 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php
@@ -26,7 +26,7 @@ abstract class BaseFeatureCategoryPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'feature_category';
@@ -384,12 +384,6 @@ abstract class BaseFeatureCategoryPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CategoryPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CategoryPeer::clearInstancePool();
- // Invalidate objects in FeaturePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FeaturePeer::clearInstancePool();
}
/**
@@ -486,6 +480,637 @@ abstract class BaseFeatureCategoryPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Feature table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinFeature(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of FeatureCategory objects pre-filled with their Category objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+ }
+
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ $startcol = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FeatureCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (FeatureCategory) to $obj2 (Category)
+ $obj2->addFeatureCategory($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of FeatureCategory objects pre-filled with their Feature objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+ }
+
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ $startcol = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
+ FeaturePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FeatureCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FeaturePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FeaturePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (FeatureCategory) to $obj2 (Feature)
+ $obj2->addFeatureCategory($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of FeatureCategory objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+ }
+
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ FeaturePeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + FeaturePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (FeatureCategory) to the collection in $obj2 (Category)
+ $obj2->addFeatureCategory($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Feature rows
+
+ $key3 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = FeaturePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ FeaturePeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (FeatureCategory) to the collection in $obj3 (Feature)
+ $obj3->addFeatureCategory($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Feature table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptFeature(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of FeatureCategory objects pre-filled with all related objects except Category.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+ }
+
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ FeaturePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Feature rows
+
+ $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FeaturePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FeaturePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (FeatureCategory) to the collection in $obj2 (Feature)
+ $obj2->addFeatureCategory($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of FeatureCategory objects pre-filled with all related objects except Feature.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+ }
+
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (FeatureCategory) to the collection in $obj2 (Category)
+ $obj2->addFeatureCategory($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -619,7 +1244,6 @@ abstract class BaseFeatureCategoryPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += FeatureCategoryPeer::doOnDeleteCascade(new Criteria(FeatureCategoryPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(FeatureCategoryPeer::TABLE_NAME, $con, FeatureCategoryPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -653,14 +1277,24 @@ abstract class BaseFeatureCategoryPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ FeatureCategoryPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof FeatureCategory) { // it's a model object
+ // invalidate the cache for this single object
+ FeatureCategoryPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME);
$criteria->add(FeatureCategoryPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ FeatureCategoryPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -673,23 +1307,6 @@ abstract class BaseFeatureCategoryPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += FeatureCategoryPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- FeatureCategoryPeer::clearInstancePool();
- } elseif ($values instanceof FeatureCategory) { // it's a model object
- FeatureCategoryPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- FeatureCategoryPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
FeatureCategoryPeer::clearRelatedInstancePool();
$con->commit();
@@ -701,45 +1318,6 @@ abstract class BaseFeatureCategoryPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = FeatureCategoryPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Category objects
- $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
-
- $criteria->add(CategoryPeer::ID, $obj->getCategoryId());
- $affectedRows += CategoryPeer::doDelete($criteria, $con);
-
- // delete related Feature objects
- $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
-
- $criteria->add(FeaturePeer::ID, $obj->getFeatureId());
- $affectedRows += FeaturePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given FeatureCategory object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php
index 143b56127..262bd682a 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php
@@ -73,7 +73,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\FeatureCategory', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\FeatureCategory', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -276,6 +276,8 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria
* $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
*
*
+ * @see filterByFeature()
+ *
* @param mixed $featureId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -317,6 +319,8 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
*
*
+ * @see filterByCategory()
+ *
* @param mixed $categoryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -437,7 +441,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria
/**
* Filter the query by a related Category object
*
- * @param Category|PropelObjectCollection $category the related object to use as filter
+ * @param Category|PropelObjectCollection $category The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FeatureCategoryQuery The current query, for fluid interface
@@ -449,10 +453,12 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $category->getId(), $comparison);
} elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCategoryQuery()
- ->filterByPrimaryKeys($category->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
}
@@ -511,7 +517,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria
/**
* Filter the query by a related Feature object
*
- * @param Feature|PropelObjectCollection $feature the related object to use as filter
+ * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FeatureCategoryQuery The current query, for fluid interface
@@ -523,10 +529,12 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $feature->getId(), $comparison);
} elseif ($feature instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useFeatureQuery()
- ->filterByPrimaryKeys($feature->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureDesc.php b/core/lib/Thelia/Model/om/BaseFeatureDesc.php
index e412097e9..f33be3c8f 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureDesc.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Feature;
use Thelia\Model\FeatureDesc;
@@ -98,9 +96,9 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Feature one-to-one related Feature object
+ * @var Feature
*/
- protected $singleFeature;
+ protected $aFeature;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $featuresScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -294,6 +286,10 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureDescPeer::FEATURE_ID;
}
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
return $this;
} // setFeatureId()
@@ -499,6 +495,9 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
} // ensureConsistency
/**
@@ -538,8 +537,7 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleFeature = null;
-
+ $this->aFeature = null;
} // if (deep)
}
@@ -653,6 +651,18 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFeature !== null) {
+ if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
+ $affectedRows += $this->aFeature->save($con);
+ }
+ $this->setFeature($this->aFeature);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -664,21 +674,6 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->featuresScheduledForDeletion !== null) {
- if (!$this->featuresScheduledForDeletion->isEmpty()) {
- FeatureQuery::create()
- ->filterByPrimaryKeys($this->featuresScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->featuresScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFeature !== null) {
- if (!$this->singleFeature->isDeleted()) {
- $affectedRows += $this->singleFeature->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -858,17 +853,23 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFeature !== null) {
+ if (!$this->aFeature->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures());
+ }
+ }
+
+
if (($retval = FeatureDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleFeature !== null) {
- if (!$this->singleFeature->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFeature->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -967,8 +968,8 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleFeature) {
- $result['Feature'] = $this->singleFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1157,11 +1158,6 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getFeature();
- if ($relObj) {
- $copyObj->setFeature($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1212,55 +1208,57 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Feature object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Feature object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Feature
- * @throws PropelException
- */
- public function getFeature(PropelPDO $con = null)
- {
-
- if ($this->singleFeature === null && !$this->isNew()) {
- $this->singleFeature = FeatureQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleFeature;
- }
-
- /**
- * Sets a single Feature object as related to this object by a one-to-one relationship.
- *
- * @param Feature $v Feature
+ * @param Feature $v
* @return FeatureDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setFeature(Feature $v = null)
{
- $this->singleFeature = $v;
-
- // Make sure that that the passed-in Feature isn't already associated with this object
- if ($v !== null && $v->getFeatureDesc() === null) {
- $v->setFeatureDesc($this);
+ if ($v === null) {
+ $this->setFeatureId(NULL);
+ } else {
+ $this->setFeatureId($v->getId());
}
+ $this->aFeature = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Feature object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Feature object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Feature The associated Feature object.
+ * @throws PropelException
+ */
+ public function getFeature(PropelPDO $con = null)
+ {
+ if ($this->aFeature === null && ($this->feature_id !== null)) {
+ $this->aFeature = FeatureQuery::create()->findPk($this->feature_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->aFeature->addFeatureDescs($this);
+ */
+ }
+
+ return $this->aFeature;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1294,15 +1292,9 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleFeature) {
- $this->singleFeature->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleFeature instanceof PropelCollection) {
- $this->singleFeature->clearIterator();
- }
- $this->singleFeature = null;
+ $this->aFeature = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseFeatureDescPeer.php b/core/lib/Thelia/Model/om/BaseFeatureDescPeer.php
index 35ac23200..1557012c2 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseFeatureDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'feature_desc';
@@ -398,9 +398,6 @@ abstract class BaseFeatureDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in FeaturePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FeaturePeer::clearInstancePool();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseFeatureDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Feature table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinFeature(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureDescPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of FeatureDesc objects pre-filled with their Feature objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME);
+ }
+
+ FeatureDescPeer::addSelectColumns($criteria);
+ $startcol = FeatureDescPeer::NUM_HYDRATE_COLUMNS;
+ FeaturePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FeatureDescPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FeatureDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FeaturePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FeaturePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (FeatureDesc) to $obj2 (Feature)
+ $obj2->addFeatureDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureDescPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of FeatureDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME);
+ }
+
+ FeatureDescPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureDescPeer::NUM_HYDRATE_COLUMNS;
+
+ FeaturePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FeatureDescPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Feature rows
+
+ $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FeaturePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FeaturePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (FeatureDesc) to the collection in $obj2 (Feature)
+ $obj2->addFeatureDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -630,7 +865,6 @@ abstract class BaseFeatureDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += FeatureDescPeer::doOnDeleteCascade(new Criteria(FeatureDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(FeatureDescPeer::TABLE_NAME, $con, FeatureDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +898,24 @@ abstract class BaseFeatureDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ FeatureDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof FeatureDesc) { // it's a model object
+ // invalidate the cache for this single object
+ FeatureDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(FeatureDescPeer::DATABASE_NAME);
$criteria->add(FeatureDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ FeatureDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,23 +928,6 @@ abstract class BaseFeatureDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += FeatureDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- FeatureDescPeer::clearInstancePool();
- } elseif ($values instanceof FeatureDesc) { // it's a model object
- FeatureDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- FeatureDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
FeatureDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -712,39 +939,6 @@ abstract class BaseFeatureDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = FeatureDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Feature objects
- $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
-
- $criteria->add(FeaturePeer::ID, $obj->getFeatureId());
- $affectedRows += FeaturePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given FeatureDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php b/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php
index 4d9ab4eb6..bf5bc3372 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseFeatureDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\FeatureDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\FeatureDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -283,6 +283,8 @@ abstract class BaseFeatureDescQuery extends ModelCriteria
* $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
*
*
+ * @see filterByFeature()
+ *
* @param mixed $featureId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +521,7 @@ abstract class BaseFeatureDescQuery extends ModelCriteria
/**
* Filter the query by a related Feature object
*
- * @param Feature|PropelObjectCollection $feature the related object to use as filter
+ * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FeatureDescQuery The current query, for fluid interface
@@ -531,10 +533,12 @@ abstract class BaseFeatureDescQuery extends ModelCriteria
return $this
->addUsingAlias(FeatureDescPeer::FEATURE_ID, $feature->getId(), $comparison);
} elseif ($feature instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useFeatureQuery()
- ->filterByPrimaryKeys($feature->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(FeatureDescPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseFeaturePeer.php b/core/lib/Thelia/Model/om/BaseFeaturePeer.php
index c34654170..b5d43299c 100644
--- a/core/lib/Thelia/Model/om/BaseFeaturePeer.php
+++ b/core/lib/Thelia/Model/om/BaseFeaturePeer.php
@@ -28,7 +28,7 @@ abstract class BaseFeaturePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'feature';
@@ -386,6 +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 FeatureProdPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ FeatureProdPeer::clearInstancePool();
}
/**
@@ -482,1385 +494,6 @@ abstract class BaseFeaturePeer
return array($obj, $col);
}
-
- /**
- * 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.
- * @param PropelPDO $con
- * @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)
- {
- // we're going to modify criteria, so copy it first
- $criteria = clone $criteria;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinFeatureCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinFeatureDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureProd table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinFeatureProd(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Feature 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
- * @return array Array of Feature objects.
- * @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)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol = FeaturePeer::NUM_HYDRATE_COLUMNS;
- FeatureAvPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- FeatureAvPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Feature) to $obj2 (FeatureAv)
- // one to one relationship
- $obj1->setFeatureAv($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Feature objects pre-filled with their FeatureCategory objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Feature objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinFeatureCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol = FeaturePeer::NUM_HYDRATE_COLUMNS;
- FeatureCategoryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = FeatureCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- FeatureCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Feature) to $obj2 (FeatureCategory)
- // one to one relationship
- $obj1->setFeatureCategory($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Feature objects pre-filled with their FeatureDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Feature objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinFeatureDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol = FeaturePeer::NUM_HYDRATE_COLUMNS;
- FeatureDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = FeatureDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = FeatureDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- FeatureDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Feature) to $obj2 (FeatureDesc)
- // one to one relationship
- $obj1->setFeatureDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Feature objects pre-filled with their FeatureProd objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Feature objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinFeatureProd(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol = FeaturePeer::NUM_HYDRATE_COLUMNS;
- FeatureProdPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = FeatureProdPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- FeatureProdPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Feature) to $obj2 (FeatureProd)
- // one to one relationship
- $obj1->setFeatureProd($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Feature objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Feature objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol2 = FeaturePeer::NUM_HYDRATE_COLUMNS;
-
- FeatureAvPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FeatureDescPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined FeatureAv rows
-
- $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- FeatureAvPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Feature) to the collection in $obj2 (FeatureAv)
- $obj1->setFeatureAv($obj2);
- } // if joined row not null
-
- // Add objects for joined FeatureCategory rows
-
- $key3 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = FeatureCategoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- FeatureCategoryPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Feature) to the collection in $obj3 (FeatureCategory)
- $obj1->setFeatureCategory($obj3);
- } // if joined row not null
-
- // Add objects for joined FeatureDesc rows
-
- $key4 = FeatureDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FeatureDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FeatureDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FeatureDescPeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (Feature) to the collection in $obj4 (FeatureDesc)
- $obj1->setFeatureDesc($obj4);
- } // if joined row not null
-
- // Add objects for joined FeatureProd rows
-
- $key5 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = FeatureProdPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- FeatureProdPeer::addInstanceToPool($obj5, $key5);
- } // if obj5 loaded
-
- // Add the $obj1 (Feature) to the collection in $obj5 (FeatureProd)
- $obj1->setFeatureProd($obj5);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * 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.
- * @param PropelPDO $con
- * @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)
- {
- // we're going to modify criteria, so copy it first
- $criteria = clone $criteria;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptFeatureCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptFeatureDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureProd table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptFeatureProd(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FeaturePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Feature objects pre-filled with all related objects except FeatureAv.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Feature objects.
- * @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)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol2 = FeaturePeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + FeatureDescPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined FeatureCategory rows
-
- $key2 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = FeatureCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- FeatureCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj2 (FeatureCategory)
- $obj1->setFeatureCategory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureDesc rows
-
- $key3 = FeatureDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = FeatureDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = FeatureDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- FeatureDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj3 (FeatureDesc)
- $obj1->setFeatureDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key4 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FeatureProdPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FeatureProdPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj4 (FeatureProd)
- $obj1->setFeatureProd($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Feature objects pre-filled with all related objects except FeatureCategory.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Feature objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptFeatureCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol2 = FeaturePeer::NUM_HYDRATE_COLUMNS;
-
- FeatureAvPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + FeatureDescPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined FeatureAv rows
-
- $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- FeatureAvPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj2 (FeatureAv)
- $obj1->setFeatureAv($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureDesc rows
-
- $key3 = FeatureDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = FeatureDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = FeatureDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- FeatureDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj3 (FeatureDesc)
- $obj1->setFeatureDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key4 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FeatureProdPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FeatureProdPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj4 (FeatureProd)
- $obj1->setFeatureProd($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Feature objects pre-filled with all related objects except FeatureDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Feature objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptFeatureDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol2 = FeaturePeer::NUM_HYDRATE_COLUMNS;
-
- FeatureAvPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureProdPeer::FEATURE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined FeatureAv rows
-
- $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- FeatureAvPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj2 (FeatureAv)
- $obj1->setFeatureAv($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key3 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = FeatureCategoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- FeatureCategoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj3 (FeatureCategory)
- $obj1->setFeatureCategory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key4 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FeatureProdPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FeatureProdPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj4 (FeatureProd)
- $obj1->setFeatureProd($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Feature objects pre-filled with all related objects except FeatureProd.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Feature objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptFeatureProd(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FeaturePeer::DATABASE_NAME);
- }
-
- FeaturePeer::addSelectColumns($criteria);
- $startcol2 = FeaturePeer::NUM_HYDRATE_COLUMNS;
-
- FeatureAvPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureCategoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FeatureDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FeaturePeer::ID, FeatureAvPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureCategoryPeer::FEATURE_ID, $join_behavior);
-
- $criteria->addJoin(FeaturePeer::ID, FeatureDescPeer::FEATURE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FeaturePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FeaturePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FeaturePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined FeatureAv rows
-
- $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureAvPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- FeatureAvPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj2 (FeatureAv)
- $obj1->setFeatureAv($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureCategory rows
-
- $key3 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = FeatureCategoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = FeatureCategoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- FeatureCategoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj3 (FeatureCategory)
- $obj1->setFeatureCategory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureDesc rows
-
- $key4 = FeatureDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FeatureDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FeatureDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FeatureDescPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Feature) to the collection in $obj4 (FeatureDesc)
- $obj1->setFeatureDesc($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseFeatureProd.php b/core/lib/Thelia/Model/om/BaseFeatureProd.php
index 1376681c2..b38cf038a 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureProd.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureProd.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Feature;
use Thelia\Model\FeatureAv;
@@ -102,19 +100,19 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Feature one-to-one related Feature object
+ * @var FeatureAv
*/
- protected $singleFeature;
+ protected $aFeatureAv;
/**
- * @var FeatureAv one-to-one related FeatureAv object
+ * @var Feature
*/
- protected $singleFeatureAv;
+ protected $aFeature;
/**
- * @var Product one-to-one related Product object
+ * @var Product
*/
- protected $singleProduct;
+ protected $aProduct;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -130,24 +128,6 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $featuresScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $featureAvsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -320,6 +300,10 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureProdPeer::PRODUCT_ID;
}
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
return $this;
} // setProductId()
@@ -341,6 +325,10 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureProdPeer::FEATURE_ID;
}
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
return $this;
} // setFeatureId()
@@ -362,6 +350,10 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
$this->modifiedColumns[] = FeatureProdPeer::FEATURE_AV_ID;
}
+ if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) {
+ $this->aFeatureAv = null;
+ }
+
return $this;
} // setFeatureAvId()
@@ -525,6 +517,15 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
+ if ($this->aFeatureAv !== null && $this->feature_av_id !== $this->aFeatureAv->getId()) {
+ $this->aFeatureAv = null;
+ }
} // ensureConsistency
/**
@@ -564,12 +565,9 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleFeature = null;
-
- $this->singleFeatureAv = null;
-
- $this->singleProduct = null;
-
+ $this->aFeatureAv = null;
+ $this->aFeature = null;
+ $this->aProduct = null;
} // if (deep)
}
@@ -683,6 +681,32 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // 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);
+ }
+ $this->setFeatureAv($this->aFeatureAv);
+ }
+
+ if ($this->aFeature !== null) {
+ if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
+ $affectedRows += $this->aFeature->save($con);
+ }
+ $this->setFeature($this->aFeature);
+ }
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -694,51 +718,6 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->featuresScheduledForDeletion !== null) {
- if (!$this->featuresScheduledForDeletion->isEmpty()) {
- FeatureQuery::create()
- ->filterByPrimaryKeys($this->featuresScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->featuresScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFeature !== null) {
- if (!$this->singleFeature->isDeleted()) {
- $affectedRows += $this->singleFeature->save($con);
- }
- }
-
- if ($this->featureAvsScheduledForDeletion !== null) {
- if (!$this->featureAvsScheduledForDeletion->isEmpty()) {
- FeatureAvQuery::create()
- ->filterByPrimaryKeys($this->featureAvsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->featureAvsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFeatureAv !== null) {
- if (!$this->singleFeatureAv->isDeleted()) {
- $affectedRows += $this->singleFeatureAv->save($con);
- }
- }
-
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -918,29 +897,35 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // 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->aFeature !== null) {
+ if (!$this->aFeature->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures());
+ }
+ }
+
+ if ($this->aProduct !== null) {
+ if (!$this->aProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
+ }
+ }
+
+
if (($retval = FeatureProdPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleFeature !== null) {
- if (!$this->singleFeature->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFeature->getValidationFailures());
- }
- }
-
- if ($this->singleFeatureAv !== null) {
- if (!$this->singleFeatureAv->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFeatureAv->getValidationFailures());
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -1039,14 +1024,14 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleFeature) {
- $result['Feature'] = $this->singleFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFeatureAv) {
+ $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleFeatureAv) {
- $result['FeatureAv'] = $this->singleFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1235,21 +1220,6 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getFeature();
- if ($relObj) {
- $copyObj->setFeature($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getFeatureAv();
- if ($relObj) {
- $copyObj->setFeatureAv($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1300,127 +1270,159 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a FeatureAv object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Feature object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Feature
- * @throws PropelException
- */
- public function getFeature(PropelPDO $con = null)
- {
-
- if ($this->singleFeature === null && !$this->isNew()) {
- $this->singleFeature = FeatureQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleFeature;
- }
-
- /**
- * Sets a single Feature object as related to this object by a one-to-one relationship.
- *
- * @param Feature $v Feature
- * @return FeatureProd The current object (for fluent API support)
- * @throws PropelException
- */
- public function setFeature(Feature $v = null)
- {
- $this->singleFeature = $v;
-
- // Make sure that that the passed-in Feature isn't already associated with this object
- if ($v !== null && $v->getFeatureProd() === null) {
- $v->setFeatureProd($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single FeatureAv object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return FeatureAv
- * @throws PropelException
- */
- public function getFeatureAv(PropelPDO $con = null)
- {
-
- if ($this->singleFeatureAv === null && !$this->isNew()) {
- $this->singleFeatureAv = FeatureAvQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleFeatureAv;
- }
-
- /**
- * Sets a single FeatureAv object as related to this object by a one-to-one relationship.
- *
- * @param FeatureAv $v FeatureAv
+ * @param FeatureAv $v
* @return FeatureProd The current object (for fluent API support)
* @throws PropelException
*/
public function setFeatureAv(FeatureAv $v = null)
{
- $this->singleFeatureAv = $v;
-
- // Make sure that that the passed-in FeatureAv isn't already associated with this object
- if ($v !== null && $v->getFeatureProd() === null) {
- $v->setFeatureProd($this);
+ if ($v === null) {
+ $this->setFeatureAvId(NULL);
+ } else {
+ $this->setFeatureAvId($v->getId());
}
+ $this->aFeatureAv = $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 ($v !== null) {
+ $v->addFeatureProd($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
+ * Get the associated FeatureAv object
*
- * @param PropelPDO $con optional connection object
- * @return Product
+ * @param PropelPDO $con Optional Connection object.
+ * @return FeatureAv The associated FeatureAv object.
* @throws PropelException
*/
- public function getProduct(PropelPDO $con = null)
+ public function getFeatureAv(PropelPDO $con = null)
{
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $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->aFeatureAv->addFeatureProds($this);
+ */
}
- return $this->singleProduct;
+ return $this->aFeatureAv;
}
/**
- * Sets a single Product object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Feature object.
*
- * @param Product $v Product
+ * @param Feature $v
+ * @return FeatureProd The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeature(Feature $v = null)
+ {
+ if ($v === null) {
+ $this->setFeatureId(NULL);
+ } else {
+ $this->setFeatureId($v->getId());
+ }
+
+ $this->aFeature = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Feature object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureProd($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Feature object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Feature The associated Feature object.
+ * @throws PropelException
+ */
+ public function getFeature(PropelPDO $con = null)
+ {
+ if ($this->aFeature === null && ($this->feature_id !== null)) {
+ $this->aFeature = FeatureQuery::create()->findPk($this->feature_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->aFeature->addFeatureProds($this);
+ */
+ }
+
+ return $this->aFeature;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
* @return FeatureProd The current object (for fluent API support)
* @throws PropelException
*/
public function setProduct(Product $v = null)
{
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getFeatureProd() === null) {
- $v->setFeatureProd($this);
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
}
+ $this->aProduct = $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 ($v !== null) {
+ $v->addFeatureProd($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Product object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
+ * @throws PropelException
+ */
+ public function getProduct(PropelPDO $con = null)
+ {
+ 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->aProduct->addFeatureProds($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1454,29 +1456,11 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleFeature) {
- $this->singleFeature->clearAllReferences($deep);
- }
- if ($this->singleFeatureAv) {
- $this->singleFeatureAv->clearAllReferences($deep);
- }
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleFeature instanceof PropelCollection) {
- $this->singleFeature->clearIterator();
- }
- $this->singleFeature = null;
- if ($this->singleFeatureAv instanceof PropelCollection) {
- $this->singleFeatureAv->clearIterator();
- }
- $this->singleFeatureAv = null;
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
+ $this->aFeatureAv = null;
+ $this->aFeature = null;
+ $this->aProduct = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php
index 6b6d64faa..235e9cefa 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php
@@ -27,7 +27,7 @@ abstract class BaseFeatureProdPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'feature_prod';
@@ -400,15 +400,6 @@ abstract class BaseFeatureProdPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in FeaturePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FeaturePeer::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 ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
}
/**
@@ -505,6 +496,983 @@ abstract class BaseFeatureProdPeer
return array($obj, $col);
}
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureProdPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Feature table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinFeature(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureProdPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureProdPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * 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
+ * @return array Array of FeatureProd objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+ }
+
+ FeatureProdPeer::addSelectColumns($criteria);
+ $startcol = FeatureProdPeer::NUM_HYDRATE_COLUMNS;
+ FeatureAvPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FeatureProdPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureProdPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeatureAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FeatureAvPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (FeatureProd) to $obj2 (FeatureAv)
+ $obj2->addFeatureProd($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of FeatureProd objects pre-filled with their Feature objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureProd objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+ }
+
+ FeatureProdPeer::addSelectColumns($criteria);
+ $startcol = FeatureProdPeer::NUM_HYDRATE_COLUMNS;
+ FeaturePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FeatureProdPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureProdPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FeaturePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FeaturePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (FeatureProd) to $obj2 (Feature)
+ $obj2->addFeatureProd($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * 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
+ * @return array Array of FeatureProd objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+ }
+
+ FeatureProdPeer::addSelectColumns($criteria);
+ $startcol = FeatureProdPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FeatureProdPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureProdPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (FeatureProd) to $obj2 (Product)
+ $obj2->addFeatureProd($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureProdPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of FeatureProd objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureProd objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+ }
+
+ FeatureProdPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS;
+
+ FeatureAvPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS;
+
+ FeaturePeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + FeaturePeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureProdPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureProdPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined FeatureAv rows
+
+ $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeatureAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FeatureAvPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj2 (FeatureAv)
+ $obj2->addFeatureProd($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Feature rows
+
+ $key3 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = FeaturePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ FeaturePeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj3 (Feature)
+ $obj3->addFeatureProd($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Product rows
+
+ $key4 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ProductPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ProductPeer::addInstanceToPool($obj4, $key4);
+ } // if obj4 loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj4 (Product)
+ $obj4->addFeatureProd($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureProdPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Feature table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptFeature(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureProdPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $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);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FeatureProdPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of FeatureProd objects pre-filled with all related objects except FeatureAv.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureProd objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+ }
+
+ FeatureProdPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS;
+
+ FeaturePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+ $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureProdPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureProdPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Feature rows
+
+ $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FeaturePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FeaturePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj2 (Feature)
+ $obj2->addFeatureProd($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Product rows
+
+ $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ProductPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ProductPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj3 (Product)
+ $obj3->addFeatureProd($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of FeatureProd objects pre-filled with all related objects except Feature.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureProd objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+ }
+
+ 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;
+
+ $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();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureProdPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureProdPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined FeatureAv rows
+
+ $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeatureAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FeatureAvPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj2 (FeatureAv)
+ $obj2->addFeatureProd($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Product rows
+
+ $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ProductPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ProductPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj3 (Product)
+ $obj3->addFeatureProd($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of FeatureProd objects pre-filled with all related objects except Product.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FeatureProd objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+ }
+
+ FeatureProdPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS;
+
+ FeatureAvPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FeatureAvPeer::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::FEATURE_ID, FeaturePeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FeatureProdPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FeatureProdPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined FeatureAv rows
+
+ $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FeatureAvPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FeatureAvPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FeatureAvPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj2 (FeatureAv)
+ $obj2->addFeatureProd($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Feature rows
+
+ $key3 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = FeaturePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = FeaturePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ FeaturePeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (FeatureProd) to the collection in $obj3 (Feature)
+ $obj3->addFeatureProd($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -638,7 +1606,6 @@ abstract class BaseFeatureProdPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += FeatureProdPeer::doOnDeleteCascade(new Criteria(FeatureProdPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(FeatureProdPeer::TABLE_NAME, $con, FeatureProdPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -672,14 +1639,24 @@ abstract class BaseFeatureProdPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ FeatureProdPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof FeatureProd) { // it's a model object
+ // invalidate the cache for this single object
+ FeatureProdPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(FeatureProdPeer::DATABASE_NAME);
$criteria->add(FeatureProdPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ FeatureProdPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -692,23 +1669,6 @@ abstract class BaseFeatureProdPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += FeatureProdPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- FeatureProdPeer::clearInstancePool();
- } elseif ($values instanceof FeatureProd) { // it's a model object
- FeatureProdPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- FeatureProdPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
FeatureProdPeer::clearRelatedInstancePool();
$con->commit();
@@ -720,51 +1680,6 @@ abstract class BaseFeatureProdPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = FeatureProdPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Feature objects
- $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
-
- $criteria->add(FeaturePeer::ID, $obj->getFeatureId());
- $affectedRows += FeaturePeer::doDelete($criteria, $con);
-
- // delete related FeatureAv objects
- $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
-
- $criteria->add(FeatureAvPeer::ID, $obj->getFeatureAvId());
- $affectedRows += FeatureAvPeer::doDelete($criteria, $con);
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given FeatureProd object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php
index e14b51fd5..d8a0daccb 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php
@@ -46,14 +46,14 @@ 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 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 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 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
@@ -90,7 +90,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\FeatureProd', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\FeatureProd', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -293,6 +293,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProduct()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -334,6 +336,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria
* $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
*
*
+ * @see filterByFeature()
+ *
* @param mixed $featureId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -375,6 +379,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria
* $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id > 12
*
*
+ * @see filterByFeatureAv()
+ *
* @param mixed $featureAvId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -562,10 +568,86 @@ abstract class BaseFeatureProdQuery extends ModelCriteria
return $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query by a related FeatureAv object
+ *
+ * @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 filterByFeatureAv($featureAv, $comparison = null)
+ {
+ if ($featureAv instanceof FeatureAv) {
+ return $this
+ ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->getId(), $comparison);
+ } elseif ($featureAv instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } 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 FeatureProdQuery The current query, for fluid interface
+ */
+ public function joinFeatureAv($relationAlias = null, $joinType = Criteria::LEFT_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::LEFT_JOIN)
+ {
+ return $this
+ ->joinFeatureAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery');
+ }
+
/**
* Filter the query by a related Feature object
*
- * @param Feature|PropelObjectCollection $feature the related object to use as filter
+ * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FeatureProdQuery The current query, for fluid interface
@@ -577,10 +659,12 @@ abstract class BaseFeatureProdQuery extends ModelCriteria
return $this
->addUsingAlias(FeatureProdPeer::FEATURE_ID, $feature->getId(), $comparison);
} elseif ($feature instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useFeatureQuery()
- ->filterByPrimaryKeys($feature->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(FeatureProdPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection');
}
@@ -636,84 +720,10 @@ abstract class BaseFeatureProdQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery');
}
- /**
- * 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 FeatureProdQuery 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(FeatureProdPeer::FEATURE_AV_ID, $featureAv->getId(), $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 FeatureProdQuery 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 Product object
*
- * @param Product|PropelObjectCollection $product the related object 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
@@ -725,10 +735,12 @@ abstract class BaseFeatureProdQuery extends ModelCriteria
return $this
->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureQuery.php b/core/lib/Thelia/Model/om/BaseFeatureQuery.php
index f00e08916..8693b761e 100644
--- a/core/lib/Thelia/Model/om/BaseFeatureQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFeatureQuery.php
@@ -83,7 +83,7 @@ abstract class BaseFeatureQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Feature', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Feature', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -259,14 +259,6 @@ abstract class BaseFeatureQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByFeatureAv()
- *
- * @see filterByFeatureCategory()
- *
- * @see filterByFeatureDesc()
- *
- * @see filterByFeatureProd()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -455,7 +447,7 @@ abstract class BaseFeatureQuery extends ModelCriteria
/**
* Filter the query by a related FeatureAv object
*
- * @param FeatureAv|PropelObjectCollection $featureAv The related object(s) to use as filter
+ * @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
@@ -467,12 +459,10 @@ abstract class BaseFeatureQuery extends ModelCriteria
return $this
->addUsingAlias(FeaturePeer::ID, $featureAv->getFeatureId(), $comparison);
} elseif ($featureAv instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FeaturePeer::ID, $featureAv->toKeyValue('PrimaryKey', 'FeatureId'), $comparison);
+ ->useFeatureAvQuery()
+ ->filterByPrimaryKeys($featureAv->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection');
}
@@ -531,7 +521,7 @@ abstract class BaseFeatureQuery extends ModelCriteria
/**
* Filter the query by a related FeatureCategory object
*
- * @param FeatureCategory|PropelObjectCollection $featureCategory The related object(s) to use as filter
+ * @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
@@ -543,12 +533,10 @@ abstract class BaseFeatureQuery extends ModelCriteria
return $this
->addUsingAlias(FeaturePeer::ID, $featureCategory->getFeatureId(), $comparison);
} elseif ($featureCategory instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FeaturePeer::ID, $featureCategory->toKeyValue('PrimaryKey', 'FeatureId'), $comparison);
+ ->useFeatureCategoryQuery()
+ ->filterByPrimaryKeys($featureCategory->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection');
}
@@ -607,7 +595,7 @@ abstract class BaseFeatureQuery extends ModelCriteria
/**
* Filter the query by a related FeatureDesc object
*
- * @param FeatureDesc|PropelObjectCollection $featureDesc The related object(s) to use as filter
+ * @param FeatureDesc|PropelObjectCollection $featureDesc 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
@@ -619,12 +607,10 @@ abstract class BaseFeatureQuery extends ModelCriteria
return $this
->addUsingAlias(FeaturePeer::ID, $featureDesc->getFeatureId(), $comparison);
} elseif ($featureDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FeaturePeer::ID, $featureDesc->toKeyValue('PrimaryKey', 'FeatureId'), $comparison);
+ ->useFeatureDescQuery()
+ ->filterByPrimaryKeys($featureDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFeatureDesc() only accepts arguments of type FeatureDesc or PropelCollection');
}
@@ -683,7 +669,7 @@ abstract class BaseFeatureQuery extends ModelCriteria
/**
* Filter the query by a related FeatureProd object
*
- * @param FeatureProd|PropelObjectCollection $featureProd The related object(s) to use as filter
+ * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FeatureQuery The current query, for fluid interface
@@ -695,12 +681,10 @@ abstract class BaseFeatureQuery extends ModelCriteria
return $this
->addUsingAlias(FeaturePeer::ID, $featureProd->getFeatureId(), $comparison);
} elseif ($featureProd instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FeaturePeer::ID, $featureProd->toKeyValue('PrimaryKey', 'FeatureId'), $comparison);
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseFolder.php b/core/lib/Thelia/Model/om/BaseFolder.php
index a824688f0..21df7c4de 100644
--- a/core/lib/Thelia/Model/om/BaseFolder.php
+++ b/core/lib/Thelia/Model/om/BaseFolder.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\ContentFolder;
use Thelia\Model\ContentFolderQuery;
@@ -98,29 +100,34 @@ abstract class BaseFolder extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var ContentFolder
+ * @var PropelObjectCollection|ContentFolder[] Collection to store aggregation of ContentFolder objects.
*/
- protected $aContentFolder;
+ protected $collContentFolders;
+ protected $collContentFoldersPartial;
/**
- * @var Document
+ * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects.
*/
- protected $aDocument;
+ protected $collDocuments;
+ protected $collDocumentsPartial;
/**
- * @var FolderDesc
+ * @var PropelObjectCollection|FolderDesc[] Collection to store aggregation of FolderDesc objects.
*/
- protected $aFolderDesc;
+ protected $collFolderDescs;
+ protected $collFolderDescsPartial;
/**
- * @var Image
+ * @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects.
*/
- protected $aImage;
+ protected $collImages;
+ protected $collImagesPartial;
/**
- * @var Rewriting
+ * @var PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects.
*/
- protected $aRewriting;
+ protected $collRewritings;
+ protected $collRewritingsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -136,6 +143,36 @@ 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
+ */
+ protected $folderDescsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $imagesScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $rewritingsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -277,26 +314,6 @@ abstract class BaseFolder extends BaseObject implements Persistent
$this->modifiedColumns[] = FolderPeer::ID;
}
- if ($this->aContentFolder !== null && $this->aContentFolder->getFolderId() !== $v) {
- $this->aContentFolder = null;
- }
-
- if ($this->aDocument !== null && $this->aDocument->getFolderId() !== $v) {
- $this->aDocument = null;
- }
-
- if ($this->aFolderDesc !== null && $this->aFolderDesc->getFolderId() !== $v) {
- $this->aFolderDesc = null;
- }
-
- if ($this->aImage !== null && $this->aImage->getFolderId() !== $v) {
- $this->aImage = null;
- }
-
- if ($this->aRewriting !== null && $this->aRewriting->getFolderId() !== $v) {
- $this->aRewriting = null;
- }
-
return $this;
} // setId()
@@ -501,21 +518,6 @@ abstract class BaseFolder extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aContentFolder !== null && $this->id !== $this->aContentFolder->getFolderId()) {
- $this->aContentFolder = null;
- }
- if ($this->aDocument !== null && $this->id !== $this->aDocument->getFolderId()) {
- $this->aDocument = null;
- }
- if ($this->aFolderDesc !== null && $this->id !== $this->aFolderDesc->getFolderId()) {
- $this->aFolderDesc = null;
- }
- if ($this->aImage !== null && $this->id !== $this->aImage->getFolderId()) {
- $this->aImage = null;
- }
- if ($this->aRewriting !== null && $this->id !== $this->aRewriting->getFolderId()) {
- $this->aRewriting = null;
- }
} // ensureConsistency
/**
@@ -555,11 +557,16 @@ abstract class BaseFolder extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aContentFolder = null;
- $this->aDocument = null;
- $this->aFolderDesc = null;
- $this->aImage = null;
- $this->aRewriting = null;
+ $this->collContentFolders = null;
+
+ $this->collDocuments = null;
+
+ $this->collFolderDescs = null;
+
+ $this->collImages = null;
+
+ $this->collRewritings = null;
+
} // if (deep)
}
@@ -673,46 +680,6 @@ abstract class BaseFolder extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aContentFolder !== null) {
- if ($this->aContentFolder->isModified() || $this->aContentFolder->isNew()) {
- $affectedRows += $this->aContentFolder->save($con);
- }
- $this->setContentFolder($this->aContentFolder);
- }
-
- if ($this->aDocument !== null) {
- if ($this->aDocument->isModified() || $this->aDocument->isNew()) {
- $affectedRows += $this->aDocument->save($con);
- }
- $this->setDocument($this->aDocument);
- }
-
- if ($this->aFolderDesc !== null) {
- if ($this->aFolderDesc->isModified() || $this->aFolderDesc->isNew()) {
- $affectedRows += $this->aFolderDesc->save($con);
- }
- $this->setFolderDesc($this->aFolderDesc);
- }
-
- if ($this->aImage !== null) {
- if ($this->aImage->isModified() || $this->aImage->isNew()) {
- $affectedRows += $this->aImage->save($con);
- }
- $this->setImage($this->aImage);
- }
-
- if ($this->aRewriting !== null) {
- if ($this->aRewriting->isModified() || $this->aRewriting->isNew()) {
- $affectedRows += $this->aRewriting->save($con);
- }
- $this->setRewriting($this->aRewriting);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -724,6 +691,94 @@ 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()
+ ->filterByPrimaryKeys($this->folderDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->folderDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFolderDescs !== null) {
+ foreach ($this->collFolderDescs 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->rewritingsScheduledForDeletion !== null) {
+ if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
+ foreach ($this->rewritingsScheduledForDeletion as $rewriting) {
+ // need to save related object because we set the relation to null
+ $rewriting->save($con);
+ }
+ $this->rewritingsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -897,47 +952,51 @@ abstract class BaseFolder extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aContentFolder !== null) {
- if (!$this->aContentFolder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aContentFolder->getValidationFailures());
- }
- }
-
- if ($this->aDocument !== null) {
- if (!$this->aDocument->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aDocument->getValidationFailures());
- }
- }
-
- if ($this->aFolderDesc !== null) {
- if (!$this->aFolderDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aFolderDesc->getValidationFailures());
- }
- }
-
- if ($this->aImage !== null) {
- if (!$this->aImage->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aImage->getValidationFailures());
- }
- }
-
- if ($this->aRewriting !== null) {
- if (!$this->aRewriting->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aRewriting->getValidationFailures());
- }
- }
-
-
if (($retval = FolderPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ 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)) {
+ $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->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1032,20 +1091,20 @@ abstract class BaseFolder extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aContentFolder) {
- $result['ContentFolder'] = $this->aContentFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collContentFolders) {
+ $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aDocument) {
- $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aFolderDesc) {
- $result['FolderDesc'] = $this->aFolderDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFolderDescs) {
+ $result['FolderDescs'] = $this->collFolderDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aImage) {
- $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aRewriting) {
- $result['Rewriting'] = $this->aRewriting->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1228,29 +1287,34 @@ abstract class BaseFolder extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getContentFolder();
- if ($relObj) {
- $copyObj->setContentFolder($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));
+ }
}
- $relObj = $this->getDocument();
- if ($relObj) {
- $copyObj->setDocument($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));
+ }
}
- $relObj = $this->getFolderDesc();
- if ($relObj) {
- $copyObj->setFolderDesc($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));
+ }
}
- $relObj = $this->getImage();
- if ($relObj) {
- $copyObj->setImage($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));
+ }
}
- $relObj = $this->getRewriting();
- if ($relObj) {
- $copyObj->setRewriting($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));
+ }
}
//unflag object copy
@@ -1303,239 +1367,1317 @@ abstract class BaseFolder extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a ContentFolder object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param ContentFolder $v
- * @return Folder The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ 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 ('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 setContentFolder(ContentFolder $v = null)
+ public function getContentFolders($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getFolderId());
+ return count($this->collContentFolders);
}
+ }
- $this->aContentFolder = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFolder($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated ContentFolder object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ContentFolder The associated ContentFolder object.
- * @throws PropelException
+ * @param ContentFolder $contentFolder The contentFolder object to add.
*/
- public function getContentFolder(PropelPDO $con = null)
+ protected function doAddContentFolder($contentFolder)
{
- if ($this->aContentFolder === null && ($this->id !== null)) {
- $this->aContentFolder = ContentFolderQuery::create()
- ->filterByFolder($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aContentFolder->setFolder($this);
- }
-
- return $this->aContentFolder;
+ $this->collContentFolders[]= $contentFolder;
+ $contentFolder->setFolder($this);
}
/**
- * Declares an association between this object and a Document object.
+ * @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.
*
- * @param Document $v
- * @return Folder The current object (for fluent API support)
+ * 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 setDocument(Document $v = null)
+ public function getDocuments($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getFolderId());
+ return count($this->collDocuments);
}
+ }
- $this->aDocument = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFolder($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated Document object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Document The associated Document object.
- * @throws PropelException
+ * @param Document $document The document object to add.
*/
- public function getDocument(PropelPDO $con = null)
+ protected function doAddDocument($document)
{
- if ($this->aDocument === null && ($this->id !== null)) {
- $this->aDocument = DocumentQuery::create()
- ->filterByFolder($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aDocument->setFolder($this);
- }
-
- return $this->aDocument;
+ $this->collDocuments[]= $document;
+ $document->setFolder($this);
}
/**
- * Declares an association between this object and a FolderDesc object.
+ * @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.
*
- * @param FolderDesc $v
- * @return Folder The current object (for fluent API support)
+ * 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 collFolderDescs 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 addFolderDescs()
+ */
+ public function clearFolderDescs()
+ {
+ $this->collFolderDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collFolderDescsPartial = null;
+ }
+
+ /**
+ * reset is the collFolderDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialFolderDescs($v = true)
+ {
+ $this->collFolderDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFolderDescs collection.
+ *
+ * By default this just sets the collFolderDescs collection to an empty array (like clearcollFolderDescs());
+ * 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 initFolderDescs($overrideExisting = true)
+ {
+ if (null !== $this->collFolderDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collFolderDescs = new PropelObjectCollection();
+ $this->collFolderDescs->setModel('FolderDesc');
+ }
+
+ /**
+ * Gets an array of FolderDesc 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|FolderDesc[] List of FolderDesc objects
* @throws PropelException
*/
- public function setFolderDesc(FolderDesc $v = null)
+ public function getFolderDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collFolderDescsPartial && !$this->isNew();
+ if (null === $this->collFolderDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFolderDescs) {
+ // return empty collection
+ $this->initFolderDescs();
+ } else {
+ $collFolderDescs = FolderDescQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collFolderDescsPartial && count($collFolderDescs)) {
+ $this->initFolderDescs(false);
+
+ foreach($collFolderDescs as $obj) {
+ if (false == $this->collFolderDescs->contains($obj)) {
+ $this->collFolderDescs->append($obj);
+ }
+ }
+
+ $this->collFolderDescsPartial = true;
+ }
+
+ return $collFolderDescs;
+ }
+
+ if($partial && $this->collFolderDescs) {
+ foreach($this->collFolderDescs as $obj) {
+ if($obj->isNew()) {
+ $collFolderDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collFolderDescs = $collFolderDescs;
+ $this->collFolderDescsPartial = false;
+ }
+ }
+
+ return $this->collFolderDescs;
+ }
+
+ /**
+ * Sets a collection of FolderDesc 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 $folderDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setFolderDescs(PropelCollection $folderDescs, PropelPDO $con = null)
+ {
+ $this->folderDescsScheduledForDeletion = $this->getFolderDescs(new Criteria(), $con)->diff($folderDescs);
+
+ foreach ($this->folderDescsScheduledForDeletion as $folderDescRemoved) {
+ $folderDescRemoved->setFolder(null);
+ }
+
+ $this->collFolderDescs = null;
+ foreach ($folderDescs as $folderDesc) {
+ $this->addFolderDesc($folderDesc);
+ }
+
+ $this->collFolderDescs = $folderDescs;
+ $this->collFolderDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related FolderDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related FolderDesc objects.
+ * @throws PropelException
+ */
+ public function countFolderDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collFolderDescsPartial && !$this->isNew();
+ if (null === $this->collFolderDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFolderDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getFolderDescs());
+ }
+ $query = FolderDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getFolderId());
+ return count($this->collFolderDescs);
}
+ }
- $this->aFolderDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFolder($this);
+ /**
+ * Method called to associate a FolderDesc object to this object
+ * through the FolderDesc foreign key attribute.
+ *
+ * @param FolderDesc $l FolderDesc
+ * @return Folder The current object (for fluent API support)
+ */
+ public function addFolderDesc(FolderDesc $l)
+ {
+ if ($this->collFolderDescs === null) {
+ $this->initFolderDescs();
+ $this->collFolderDescsPartial = true;
+ }
+ if (!$this->collFolderDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddFolderDesc($l);
}
-
return $this;
}
-
/**
- * Get the associated FolderDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return FolderDesc The associated FolderDesc object.
- * @throws PropelException
+ * @param FolderDesc $folderDesc The folderDesc object to add.
*/
- public function getFolderDesc(PropelPDO $con = null)
+ protected function doAddFolderDesc($folderDesc)
{
- if ($this->aFolderDesc === null && ($this->id !== null)) {
- $this->aFolderDesc = FolderDescQuery::create()
- ->filterByFolder($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFolderDesc->setFolder($this);
- }
-
- return $this->aFolderDesc;
+ $this->collFolderDescs[]= $folderDesc;
+ $folderDesc->setFolder($this);
}
/**
- * Declares an association between this object and a Image object.
+ * @param FolderDesc $folderDesc The folderDesc object to remove.
+ */
+ public function removeFolderDesc($folderDesc)
+ {
+ if ($this->getFolderDescs()->contains($folderDesc)) {
+ $this->collFolderDescs->remove($this->collFolderDescs->search($folderDesc));
+ if (null === $this->folderDescsScheduledForDeletion) {
+ $this->folderDescsScheduledForDeletion = clone $this->collFolderDescs;
+ $this->folderDescsScheduledForDeletion->clear();
+ }
+ $this->folderDescsScheduledForDeletion[]= $folderDesc;
+ $folderDesc->setFolder(null);
+ }
+ }
+
+ /**
+ * Clears out the collImages collection
*
- * @param Image $v
- * @return Folder The current object (for fluent API support)
+ * 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 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|Image[] List of Image objects
* @throws PropelException
*/
- public function setImage(Image $v = null)
+ public function getImages($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByFolder($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->setFolder(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
+ ->filterByFolder($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getFolderId());
+ return count($this->collImages);
}
+ }
- $this->aImage = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFolder($this);
+ /**
+ * Method called to associate a Image object to this object
+ * through the Image foreign key attribute.
+ *
+ * @param Image $l Image
+ * @return Folder 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;
}
-
/**
- * Get the associated Image object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Image The associated Image object.
- * @throws PropelException
+ * @param Image $image The image object to add.
*/
- public function getImage(PropelPDO $con = null)
+ protected function doAddImage($image)
{
- if ($this->aImage === null && ($this->id !== null)) {
- $this->aImage = ImageQuery::create()
- ->filterByFolder($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aImage->setFolder($this);
- }
-
- return $this->aImage;
+ $this->collImages[]= $image;
+ $image->setFolder($this);
}
/**
- * Declares an association between this object and a Rewriting object.
+ * @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->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 Images from storage.
*
- * @param Rewriting $v
- * @return Folder The current object (for fluent API support)
+ * 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|Image[] List of Image objects
+ */
+ public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = ImageQuery::create(null, $criteria);
+ $query->joinWith('Product', $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 Folder is new, it will return
+ * an empty collection; or if this Folder 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 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|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 Folder is new, it will return
+ * an empty collection; or if this Folder 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 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|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);
+ }
+
+ /**
+ * Clears out the collRewritings 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 addRewritings()
+ */
+ public function clearRewritings()
+ {
+ $this->collRewritings = null; // important to set this to null since that means it is uninitialized
+ $this->collRewritingsPartial = null;
+ }
+
+ /**
+ * reset is the collRewritings collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialRewritings($v = true)
+ {
+ $this->collRewritingsPartial = $v;
+ }
+
+ /**
+ * Initializes the collRewritings collection.
+ *
+ * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
+ * 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 initRewritings($overrideExisting = true)
+ {
+ if (null !== $this->collRewritings && !$overrideExisting) {
+ return;
+ }
+ $this->collRewritings = new PropelObjectCollection();
+ $this->collRewritings->setModel('Rewriting');
+ }
+
+ /**
+ * Gets an array of Rewriting 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|Rewriting[] List of Rewriting objects
* @throws PropelException
*/
- public function setRewriting(Rewriting $v = null)
+ public function getRewritings($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ // return empty collection
+ $this->initRewritings();
+ } else {
+ $collRewritings = RewritingQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collRewritingsPartial && count($collRewritings)) {
+ $this->initRewritings(false);
+
+ foreach($collRewritings as $obj) {
+ if (false == $this->collRewritings->contains($obj)) {
+ $this->collRewritings->append($obj);
+ }
+ }
+
+ $this->collRewritingsPartial = true;
+ }
+
+ return $collRewritings;
+ }
+
+ if($partial && $this->collRewritings) {
+ foreach($this->collRewritings as $obj) {
+ if($obj->isNew()) {
+ $collRewritings[] = $obj;
+ }
+ }
+ }
+
+ $this->collRewritings = $collRewritings;
+ $this->collRewritingsPartial = false;
+ }
+ }
+
+ return $this->collRewritings;
+ }
+
+ /**
+ * Sets a collection of Rewriting 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 $rewritings A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
+ {
+ $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
+
+ foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) {
+ $rewritingRemoved->setFolder(null);
+ }
+
+ $this->collRewritings = null;
+ foreach ($rewritings as $rewriting) {
+ $this->addRewriting($rewriting);
+ }
+
+ $this->collRewritings = $rewritings;
+ $this->collRewritingsPartial = false;
+ }
+
+ /**
+ * Returns the number of related Rewriting objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Rewriting objects.
+ * @throws PropelException
+ */
+ public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getRewritings());
+ }
+ $query = RewritingQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getFolderId());
+ return count($this->collRewritings);
}
+ }
- $this->aRewriting = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setFolder($this);
+ /**
+ * Method called to associate a Rewriting object to this object
+ * through the Rewriting foreign key attribute.
+ *
+ * @param Rewriting $l Rewriting
+ * @return Folder The current object (for fluent API support)
+ */
+ public function addRewriting(Rewriting $l)
+ {
+ if ($this->collRewritings === null) {
+ $this->initRewritings();
+ $this->collRewritingsPartial = true;
+ }
+ if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddRewriting($l);
}
-
return $this;
}
+ /**
+ * @param Rewriting $rewriting The rewriting object to add.
+ */
+ protected function doAddRewriting($rewriting)
+ {
+ $this->collRewritings[]= $rewriting;
+ $rewriting->setFolder($this);
+ }
/**
- * Get the associated Rewriting object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Rewriting The associated Rewriting object.
- * @throws PropelException
+ * @param Rewriting $rewriting The rewriting object to remove.
*/
- public function getRewriting(PropelPDO $con = null)
+ public function removeRewriting($rewriting)
{
- if ($this->aRewriting === null && ($this->id !== null)) {
- $this->aRewriting = RewritingQuery::create()
- ->filterByFolder($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aRewriting->setFolder($this);
+ if ($this->getRewritings()->contains($rewriting)) {
+ $this->collRewritings->remove($this->collRewritings->search($rewriting));
+ if (null === $this->rewritingsScheduledForDeletion) {
+ $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
+ $this->rewritingsScheduledForDeletion->clear();
+ }
+ $this->rewritingsScheduledForDeletion[]= $rewriting;
+ $rewriting->setFolder(null);
}
+ }
- return $this->aRewriting;
+
+ /**
+ * 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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getRewritings($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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Category', $join_behavior);
+
+ return $this->getRewritings($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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Content', $join_behavior);
+
+ return $this->getRewritings($query, $con);
}
/**
@@ -1570,13 +2712,53 @@ 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);
+ }
+ }
+ if ($this->collImages) {
+ foreach ($this->collImages as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collRewritings) {
+ foreach ($this->collRewritings as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aContentFolder = null;
- $this->aDocument = null;
- $this->aFolderDesc = null;
- $this->aImage = null;
- $this->aRewriting = null;
+ 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();
+ }
+ $this->collFolderDescs = null;
+ if ($this->collImages instanceof PropelCollection) {
+ $this->collImages->clearIterator();
+ }
+ $this->collImages = null;
+ if ($this->collRewritings instanceof PropelCollection) {
+ $this->collRewritings->clearIterator();
+ }
+ $this->collRewritings = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseFolderDesc.php b/core/lib/Thelia/Model/om/BaseFolderDesc.php
index 117ac0cee..39392a103 100644
--- a/core/lib/Thelia/Model/om/BaseFolderDesc.php
+++ b/core/lib/Thelia/Model/om/BaseFolderDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Folder;
use Thelia\Model\FolderDesc;
@@ -104,9 +102,9 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Folder one-to-one related Folder object
+ * @var Folder
*/
- protected $singleFolder;
+ protected $aFolder;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -122,12 +120,6 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $foldersScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -310,6 +302,10 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = FolderDescPeer::FOLDER_ID;
}
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
return $this;
} // setFolderId()
@@ -537,6 +533,9 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
} // ensureConsistency
/**
@@ -576,8 +575,7 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleFolder = null;
-
+ $this->aFolder = null;
} // if (deep)
}
@@ -691,6 +689,18 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -702,21 +712,6 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->foldersScheduledForDeletion !== null) {
- if (!$this->foldersScheduledForDeletion->isEmpty()) {
- FolderQuery::create()
- ->filterByPrimaryKeys($this->foldersScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->foldersScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->isDeleted()) {
- $affectedRows += $this->singleFolder->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -902,17 +897,23 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFolder !== null) {
+ if (!$this->aFolder->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures());
+ }
+ }
+
+
if (($retval = FolderDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFolder->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -1015,8 +1016,8 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
$keys[8] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleFolder) {
- $result['Folder'] = $this->singleFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1211,11 +1212,6 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getFolder();
- if ($relObj) {
- $copyObj->setFolder($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1266,55 +1262,57 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Folder object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Folder object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Folder
- * @throws PropelException
- */
- public function getFolder(PropelPDO $con = null)
- {
-
- if ($this->singleFolder === null && !$this->isNew()) {
- $this->singleFolder = FolderQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleFolder;
- }
-
- /**
- * Sets a single Folder object as related to this object by a one-to-one relationship.
- *
- * @param Folder $v Folder
+ * @param Folder $v
* @return FolderDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setFolder(Folder $v = null)
{
- $this->singleFolder = $v;
-
- // Make sure that that the passed-in Folder isn't already associated with this object
- if ($v !== null && $v->getFolderDesc() === null) {
- $v->setFolderDesc($this);
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
}
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Folder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFolderDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Folder object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Folder The associated Folder object.
+ * @throws PropelException
+ */
+ public function getFolder(PropelPDO $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = FolderQuery::create()->findPk($this->folder_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->aFolder->addFolderDescs($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1349,15 +1347,9 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleFolder) {
- $this->singleFolder->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleFolder instanceof PropelCollection) {
- $this->singleFolder->clearIterator();
- }
- $this->singleFolder = null;
+ $this->aFolder = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseFolderDescPeer.php b/core/lib/Thelia/Model/om/BaseFolderDescPeer.php
index 9cef1b365..92d614047 100644
--- a/core/lib/Thelia/Model/om/BaseFolderDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseFolderDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseFolderDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'folder_desc';
@@ -403,9 +403,6 @@ abstract class BaseFolderDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in FolderPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FolderPeer::clearInstancePool();
}
/**
@@ -502,6 +499,244 @@ abstract class BaseFolderDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FolderDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FolderDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FolderDescPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of FolderDesc objects pre-filled with their Folder objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FolderDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME);
+ }
+
+ FolderDescPeer::addSelectColumns($criteria);
+ $startcol = FolderDescPeer::NUM_HYDRATE_COLUMNS;
+ FolderPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FolderDescPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FolderDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FolderDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FolderDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FolderDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FolderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FolderPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (FolderDesc) to $obj2 (Folder)
+ $obj2->addFolderDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(FolderDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FolderDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FolderDescPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of FolderDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of FolderDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME);
+ }
+
+ FolderDescPeer::addSelectColumns($criteria);
+ $startcol2 = FolderDescPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FolderDescPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FolderDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FolderDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FolderDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FolderDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Folder rows
+
+ $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = FolderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ FolderPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (FolderDesc) to the collection in $obj2 (Folder)
+ $obj2->addFolderDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -635,7 +870,6 @@ abstract class BaseFolderDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += FolderDescPeer::doOnDeleteCascade(new Criteria(FolderDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(FolderDescPeer::TABLE_NAME, $con, FolderDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -669,14 +903,24 @@ abstract class BaseFolderDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ FolderDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof FolderDesc) { // it's a model object
+ // invalidate the cache for this single object
+ FolderDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(FolderDescPeer::DATABASE_NAME);
$criteria->add(FolderDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ FolderDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -689,23 +933,6 @@ abstract class BaseFolderDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += FolderDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- FolderDescPeer::clearInstancePool();
- } elseif ($values instanceof FolderDesc) { // it's a model object
- FolderDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- FolderDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
FolderDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -717,39 +944,6 @@ abstract class BaseFolderDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = FolderDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Folder objects
- $criteria = new Criteria(FolderPeer::DATABASE_NAME);
-
- $criteria->add(FolderPeer::ID, $obj->getFolderId());
- $affectedRows += FolderPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given FolderDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseFolderDescQuery.php b/core/lib/Thelia/Model/om/BaseFolderDescQuery.php
index f3f1d7a4f..761634ea3 100644
--- a/core/lib/Thelia/Model/om/BaseFolderDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFolderDescQuery.php
@@ -84,7 +84,7 @@ abstract class BaseFolderDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\FolderDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\FolderDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -287,6 +287,8 @@ abstract class BaseFolderDescQuery extends ModelCriteria
* $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
*
*
+ * @see filterByFolder()
+ *
* @param mixed $folderId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -552,7 +554,7 @@ abstract class BaseFolderDescQuery extends ModelCriteria
/**
* Filter the query by a related Folder object
*
- * @param Folder|PropelObjectCollection $folder the related object to use as filter
+ * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FolderDescQuery The current query, for fluid interface
@@ -564,10 +566,12 @@ abstract class BaseFolderDescQuery extends ModelCriteria
return $this
->addUsingAlias(FolderDescPeer::FOLDER_ID, $folder->getId(), $comparison);
} elseif ($folder instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useFolderQuery()
- ->filterByPrimaryKeys($folder->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(FolderDescPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseFolderPeer.php b/core/lib/Thelia/Model/om/BaseFolderPeer.php
index 6ff7e704d..6a45fb85b 100644
--- a/core/lib/Thelia/Model/om/BaseFolderPeer.php
+++ b/core/lib/Thelia/Model/om/BaseFolderPeer.php
@@ -29,7 +29,7 @@ abstract class BaseFolderPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'folder';
@@ -397,6 +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 RewritingPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ RewritingPeer::clearInstancePool();
}
/**
@@ -493,1836 +508,6 @@ abstract class BaseFolderPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentFolder table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinContentFolder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Document table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinDocument(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FolderDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinFolderDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Image table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinImage(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Rewriting table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinRewriting(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with their ContentFolder objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinContentFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol = FolderPeer::NUM_HYDRATE_COLUMNS;
- ContentFolderPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ContentFolderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ContentFolderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Folder) to $obj2 (ContentFolder)
- // one to one relationship
- $obj1->setContentFolder($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with their Document objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol = FolderPeer::NUM_HYDRATE_COLUMNS;
- DocumentPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = DocumentPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- DocumentPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Folder) to $obj2 (Document)
- // one to one relationship
- $obj1->setDocument($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with their FolderDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinFolderDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol = FolderPeer::NUM_HYDRATE_COLUMNS;
- FolderDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = FolderDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = FolderDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FolderDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- FolderDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Folder) to $obj2 (FolderDesc)
- // one to one relationship
- $obj1->setFolderDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with their Image objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol = FolderPeer::NUM_HYDRATE_COLUMNS;
- ImagePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ImagePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ImagePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Folder) to $obj2 (Image)
- // one to one relationship
- $obj1->setImage($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with their Rewriting objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinRewriting(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol = FolderPeer::NUM_HYDRATE_COLUMNS;
- RewritingPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = RewritingPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- RewritingPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Folder) to $obj2 (Rewriting)
- // one to one relationship
- $obj1->setRewriting($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Folder objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol2 = FolderPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FolderDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FolderDescPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentFolder rows
-
- $key2 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentFolderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentFolderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Folder) to the collection in $obj2 (ContentFolder)
- $obj1->setContentFolder($obj2);
- } // if joined row not null
-
- // Add objects for joined Document rows
-
- $key3 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = DocumentPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- DocumentPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Folder) to the collection in $obj3 (Document)
- $obj1->setDocument($obj3);
- } // if joined row not null
-
- // Add objects for joined FolderDesc rows
-
- $key4 = FolderDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FolderDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FolderDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FolderDescPeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (Folder) to the collection in $obj4 (FolderDesc)
- $obj1->setFolderDesc($obj4);
- } // if joined row not null
-
- // Add objects for joined Image rows
-
- $key5 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = ImagePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- ImagePeer::addInstanceToPool($obj5, $key5);
- } // if obj5 loaded
-
- // Add the $obj1 (Folder) to the collection in $obj5 (Image)
- $obj1->setImage($obj5);
- } // if joined row not null
-
- // Add objects for joined Rewriting rows
-
- $key6 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = RewritingPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- RewritingPeer::addInstanceToPool($obj6, $key6);
- } // if obj6 loaded
-
- // Add the $obj1 (Folder) to the collection in $obj6 (Rewriting)
- $obj1->setRewriting($obj6);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentFolder table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptContentFolder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Document table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptDocument(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FolderDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptFolderDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Image table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptImage(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Rewriting table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptRewriting(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- FolderPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with all related objects except ContentFolder.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptContentFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol2 = FolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FolderDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + FolderDescPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Document rows
-
- $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = DocumentPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- DocumentPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj2 (Document)
- $obj1->setDocument($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined FolderDesc rows
-
- $key3 = FolderDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = FolderDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = FolderDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- FolderDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj3 (FolderDesc)
- $obj1->setFolderDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key4 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ImagePeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ImagePeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj4 (Image)
- $obj1->setImage($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key5 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = RewritingPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- RewritingPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj5 (Rewriting)
- $obj1->setRewriting($obj5);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with all related objects except Document.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol2 = FolderPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- FolderDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + FolderDescPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentFolder rows
-
- $key2 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentFolderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentFolderPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj2 (ContentFolder)
- $obj1->setContentFolder($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined FolderDesc rows
-
- $key3 = FolderDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = FolderDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = FolderDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- FolderDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj3 (FolderDesc)
- $obj1->setFolderDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key4 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ImagePeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ImagePeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj4 (Image)
- $obj1->setImage($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key5 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = RewritingPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- RewritingPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj5 (Rewriting)
- $obj1->setRewriting($obj5);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with all related objects except FolderDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptFolderDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol2 = FolderPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentFolder rows
-
- $key2 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentFolderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentFolderPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj2 (ContentFolder)
- $obj1->setContentFolder($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key3 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = DocumentPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- DocumentPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj3 (Document)
- $obj1->setDocument($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key4 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ImagePeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ImagePeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj4 (Image)
- $obj1->setImage($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key5 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = RewritingPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- RewritingPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj5 (Rewriting)
- $obj1->setRewriting($obj5);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with all related objects except Image.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol2 = FolderPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FolderDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FolderDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, RewritingPeer::FOLDER_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentFolder rows
-
- $key2 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentFolderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentFolderPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj2 (ContentFolder)
- $obj1->setContentFolder($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key3 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = DocumentPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- DocumentPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj3 (Document)
- $obj1->setDocument($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined FolderDesc rows
-
- $key4 = FolderDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FolderDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FolderDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FolderDescPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj4 (FolderDesc)
- $obj1->setFolderDesc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key5 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = RewritingPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- RewritingPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj5 (Rewriting)
- $obj1->setRewriting($obj5);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Folder objects pre-filled with all related objects except Rewriting.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Folder objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptRewriting(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(FolderPeer::DATABASE_NAME);
- }
-
- FolderPeer::addSelectColumns($criteria);
- $startcol2 = FolderPeer::NUM_HYDRATE_COLUMNS;
-
- ContentFolderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FolderDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FolderDescPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(FolderPeer::ID, ContentFolderPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, DocumentPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, FolderDescPeer::FOLDER_ID, $join_behavior);
-
- $criteria->addJoin(FolderPeer::ID, ImagePeer::FOLDER_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = FolderPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = FolderPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- FolderPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentFolder rows
-
- $key2 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentFolderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentFolderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentFolderPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj2 (ContentFolder)
- $obj1->setContentFolder($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key3 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = DocumentPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- DocumentPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj3 (Document)
- $obj1->setDocument($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined FolderDesc rows
-
- $key4 = FolderDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FolderDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FolderDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FolderDescPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj4 (FolderDesc)
- $obj1->setFolderDesc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key5 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = ImagePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- ImagePeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Folder) to the collection in $obj5 (Image)
- $obj1->setImage($obj5);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseFolderQuery.php b/core/lib/Thelia/Model/om/BaseFolderQuery.php
index d66ef398d..d4e88949a 100644
--- a/core/lib/Thelia/Model/om/BaseFolderQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFolderQuery.php
@@ -96,7 +96,7 @@ abstract class BaseFolderQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Folder', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Folder', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -272,16 +272,6 @@ abstract class BaseFolderQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByContentFolder()
- *
- * @see filterByDocument()
- *
- * @see filterByFolderDesc()
- *
- * @see filterByImage()
- *
- * @see filterByRewriting()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -540,7 +530,7 @@ abstract class BaseFolderQuery extends ModelCriteria
/**
* Filter the query by a related ContentFolder object
*
- * @param ContentFolder|PropelObjectCollection $contentFolder The related object(s) to use as filter
+ * @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
@@ -552,12 +542,10 @@ abstract class BaseFolderQuery extends ModelCriteria
return $this
->addUsingAlias(FolderPeer::ID, $contentFolder->getFolderId(), $comparison);
} elseif ($contentFolder instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FolderPeer::ID, $contentFolder->toKeyValue('FolderId', 'FolderId'), $comparison);
+ ->useContentFolderQuery()
+ ->filterByPrimaryKeys($contentFolder->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection');
}
@@ -616,7 +604,7 @@ abstract class BaseFolderQuery extends ModelCriteria
/**
* Filter the query by a related Document object
*
- * @param Document|PropelObjectCollection $document The related object(s) 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 FolderQuery The current query, for fluid interface
@@ -628,12 +616,10 @@ abstract class BaseFolderQuery extends ModelCriteria
return $this
->addUsingAlias(FolderPeer::ID, $document->getFolderId(), $comparison);
} elseif ($document instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FolderPeer::ID, $document->toKeyValue('PrimaryKey', 'FolderId'), $comparison);
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
}
@@ -647,7 +633,7 @@ abstract class BaseFolderQuery extends ModelCriteria
*
* @return FolderQuery The current query, for fluid interface
*/
- public function joinDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Document');
@@ -682,7 +668,7 @@ abstract class BaseFolderQuery extends ModelCriteria
*
* @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
*/
- public function useDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinDocument($relationAlias, $joinType)
@@ -692,7 +678,7 @@ abstract class BaseFolderQuery extends ModelCriteria
/**
* Filter the query by a related FolderDesc object
*
- * @param FolderDesc|PropelObjectCollection $folderDesc The related object(s) to use as filter
+ * @param FolderDesc|PropelObjectCollection $folderDesc 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
@@ -704,12 +690,10 @@ abstract class BaseFolderQuery extends ModelCriteria
return $this
->addUsingAlias(FolderPeer::ID, $folderDesc->getFolderId(), $comparison);
} elseif ($folderDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FolderPeer::ID, $folderDesc->toKeyValue('PrimaryKey', 'FolderId'), $comparison);
+ ->useFolderDescQuery()
+ ->filterByPrimaryKeys($folderDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFolderDesc() only accepts arguments of type FolderDesc or PropelCollection');
}
@@ -768,7 +752,7 @@ abstract class BaseFolderQuery extends ModelCriteria
/**
* Filter the query by a related Image object
*
- * @param Image|PropelObjectCollection $image The related object(s) to use as filter
+ * @param Image|PropelObjectCollection $image the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FolderQuery The current query, for fluid interface
@@ -780,12 +764,10 @@ abstract class BaseFolderQuery extends ModelCriteria
return $this
->addUsingAlias(FolderPeer::ID, $image->getFolderId(), $comparison);
} elseif ($image instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FolderPeer::ID, $image->toKeyValue('PrimaryKey', 'FolderId'), $comparison);
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
}
@@ -799,7 +781,7 @@ abstract class BaseFolderQuery extends ModelCriteria
*
* @return FolderQuery The current query, for fluid interface
*/
- public function joinImage($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Image');
@@ -834,7 +816,7 @@ abstract class BaseFolderQuery extends ModelCriteria
*
* @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
*/
- public function useImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinImage($relationAlias, $joinType)
@@ -844,7 +826,7 @@ abstract class BaseFolderQuery extends ModelCriteria
/**
* Filter the query by a related Rewriting object
*
- * @param Rewriting|PropelObjectCollection $rewriting The related object(s) to use as filter
+ * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return FolderQuery The current query, for fluid interface
@@ -856,12 +838,10 @@ abstract class BaseFolderQuery extends ModelCriteria
return $this
->addUsingAlias(FolderPeer::ID, $rewriting->getFolderId(), $comparison);
} elseif ($rewriting instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(FolderPeer::ID, $rewriting->toKeyValue('PrimaryKey', 'FolderId'), $comparison);
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection');
}
@@ -875,7 +855,7 @@ abstract class BaseFolderQuery extends ModelCriteria
*
* @return FolderQuery The current query, for fluid interface
*/
- public function joinRewriting($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Rewriting');
@@ -910,7 +890,7 @@ abstract class BaseFolderQuery extends ModelCriteria
*
* @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query
*/
- public function useRewritingQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinRewriting($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseGroup.php b/core/lib/Thelia/Model/om/BaseGroup.php
index 32bbc1aec..48895894a 100644
--- a/core/lib/Thelia/Model/om/BaseGroup.php
+++ b/core/lib/Thelia/Model/om/BaseGroup.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\AdminGroup;
use Thelia\Model\AdminGroupQuery;
@@ -78,24 +80,28 @@ abstract class BaseGroup extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var AdminGroup
+ * @var PropelObjectCollection|AdminGroup[] Collection to store aggregation of AdminGroup objects.
*/
- protected $aAdminGroup;
+ protected $collAdminGroups;
+ protected $collAdminGroupsPartial;
/**
- * @var GroupDesc
+ * @var PropelObjectCollection|GroupDesc[] Collection to store aggregation of GroupDesc objects.
*/
- protected $aGroupDesc;
+ protected $collGroupDescs;
+ protected $collGroupDescsPartial;
/**
- * @var GroupModule
+ * @var PropelObjectCollection|GroupModule[] Collection to store aggregation of GroupModule objects.
*/
- protected $aGroupModule;
+ protected $collGroupModules;
+ protected $collGroupModulesPartial;
/**
- * @var GroupResource
+ * @var PropelObjectCollection|GroupResource[] Collection to store aggregation of GroupResource objects.
*/
- protected $aGroupResource;
+ protected $collGroupResources;
+ protected $collGroupResourcesPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -111,6 +117,30 @@ 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
+ */
+ protected $groupDescsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $groupModulesScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $groupResourcesScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -222,22 +252,6 @@ abstract class BaseGroup extends BaseObject implements Persistent
$this->modifiedColumns[] = GroupPeer::ID;
}
- if ($this->aAdminGroup !== null && $this->aAdminGroup->getGroupId() !== $v) {
- $this->aAdminGroup = null;
- }
-
- if ($this->aGroupDesc !== null && $this->aGroupDesc->getGroupId() !== $v) {
- $this->aGroupDesc = null;
- }
-
- if ($this->aGroupModule !== null && $this->aGroupModule->getGroupId() !== $v) {
- $this->aGroupModule = null;
- }
-
- if ($this->aGroupResource !== null && $this->aGroupResource->getGroupId() !== $v) {
- $this->aGroupResource = null;
- }
-
return $this;
} // setId()
@@ -376,18 +390,6 @@ abstract class BaseGroup extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAdminGroup !== null && $this->id !== $this->aAdminGroup->getGroupId()) {
- $this->aAdminGroup = null;
- }
- if ($this->aGroupDesc !== null && $this->id !== $this->aGroupDesc->getGroupId()) {
- $this->aGroupDesc = null;
- }
- if ($this->aGroupModule !== null && $this->id !== $this->aGroupModule->getGroupId()) {
- $this->aGroupModule = null;
- }
- if ($this->aGroupResource !== null && $this->id !== $this->aGroupResource->getGroupId()) {
- $this->aGroupResource = null;
- }
} // ensureConsistency
/**
@@ -427,10 +429,14 @@ abstract class BaseGroup extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAdminGroup = null;
- $this->aGroupDesc = null;
- $this->aGroupModule = null;
- $this->aGroupResource = null;
+ $this->collAdminGroups = null;
+
+ $this->collGroupDescs = null;
+
+ $this->collGroupModules = null;
+
+ $this->collGroupResources = null;
+
} // if (deep)
}
@@ -544,39 +550,6 @@ abstract class BaseGroup extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAdminGroup !== null) {
- if ($this->aAdminGroup->isModified() || $this->aAdminGroup->isNew()) {
- $affectedRows += $this->aAdminGroup->save($con);
- }
- $this->setAdminGroup($this->aAdminGroup);
- }
-
- if ($this->aGroupDesc !== null) {
- if ($this->aGroupDesc->isModified() || $this->aGroupDesc->isNew()) {
- $affectedRows += $this->aGroupDesc->save($con);
- }
- $this->setGroupDesc($this->aGroupDesc);
- }
-
- if ($this->aGroupModule !== null) {
- if ($this->aGroupModule->isModified() || $this->aGroupModule->isNew()) {
- $affectedRows += $this->aGroupModule->save($con);
- }
- $this->setGroupModule($this->aGroupModule);
- }
-
- if ($this->aGroupResource !== null) {
- if ($this->aGroupResource->isModified() || $this->aGroupResource->isNew()) {
- $affectedRows += $this->aGroupResource->save($con);
- }
- $this->setGroupResource($this->aGroupResource);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -588,6 +561,75 @@ abstract class BaseGroup extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->adminGroupsScheduledForDeletion !== null) {
+ if (!$this->adminGroupsScheduledForDeletion->isEmpty()) {
+ foreach ($this->adminGroupsScheduledForDeletion as $adminGroup) {
+ // need to save related object because we set the relation to null
+ $adminGroup->save($con);
+ }
+ $this->adminGroupsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAdminGroups !== null) {
+ foreach ($this->collAdminGroups as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ 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->groupModulesScheduledForDeletion !== null) {
+ if (!$this->groupModulesScheduledForDeletion->isEmpty()) {
+ GroupModuleQuery::create()
+ ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->groupModulesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collGroupModules !== null) {
+ foreach ($this->collGroupModules as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ 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;
}
@@ -743,41 +785,43 @@ abstract class BaseGroup extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aAdminGroup !== null) {
- if (!$this->aAdminGroup->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAdminGroup->getValidationFailures());
- }
- }
-
- if ($this->aGroupDesc !== null) {
- if (!$this->aGroupDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aGroupDesc->getValidationFailures());
- }
- }
-
- if ($this->aGroupModule !== null) {
- if (!$this->aGroupModule->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aGroupModule->getValidationFailures());
- }
- }
-
- if ($this->aGroupResource !== null) {
- if (!$this->aGroupResource->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aGroupResource->getValidationFailures());
- }
- }
-
-
if (($retval = GroupPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ 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)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collGroupModules !== null) {
+ foreach ($this->collGroupModules as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collGroupResources !== null) {
+ foreach ($this->collGroupResources as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -860,17 +904,17 @@ abstract class BaseGroup extends BaseObject implements Persistent
$keys[3] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAdminGroup) {
- $result['AdminGroup'] = $this->aAdminGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAdminGroups) {
+ $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aGroupDesc) {
- $result['GroupDesc'] = $this->aGroupDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collGroupDescs) {
+ $result['GroupDescs'] = $this->collGroupDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aGroupModule) {
- $result['GroupModule'] = $this->aGroupModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collGroupModules) {
+ $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aGroupResource) {
- $result['GroupResource'] = $this->aGroupResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collGroupResources) {
+ $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1035,24 +1079,28 @@ abstract class BaseGroup extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getAdminGroup();
- if ($relObj) {
- $copyObj->setAdminGroup($relObj->copy($deepCopy));
+ 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));
+ }
}
- $relObj = $this->getGroupDesc();
- if ($relObj) {
- $copyObj->setGroupDesc($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));
+ }
}
- $relObj = $this->getGroupModule();
- if ($relObj) {
- $copyObj->setGroupModule($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));
+ }
}
- $relObj = $this->getGroupResource();
- if ($relObj) {
- $copyObj->setGroupResource($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
@@ -1105,192 +1153,932 @@ abstract class BaseGroup extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a AdminGroup object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param AdminGroup $v
- * @return Group The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AdminGroup' == $relationName) {
+ $this->initAdminGroups();
+ }
+ if ('GroupDesc' == $relationName) {
+ $this->initGroupDescs();
+ }
+ if ('GroupModule' == $relationName) {
+ $this->initGroupModules();
+ }
+ if ('GroupResource' == $relationName) {
+ $this->initGroupResources();
+ }
+ }
+
+ /**
+ * Clears out the collAdminGroups 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 addAdminGroups()
+ */
+ public function clearAdminGroups()
+ {
+ $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized
+ $this->collAdminGroupsPartial = null;
+ }
+
+ /**
+ * reset is the collAdminGroups collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAdminGroups($v = true)
+ {
+ $this->collAdminGroupsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAdminGroups collection.
+ *
+ * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups());
+ * 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 initAdminGroups($overrideExisting = true)
+ {
+ if (null !== $this->collAdminGroups && !$overrideExisting) {
+ return;
+ }
+ $this->collAdminGroups = new PropelObjectCollection();
+ $this->collAdminGroups->setModel('AdminGroup');
+ }
+
+ /**
+ * Gets an array of AdminGroup 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|AdminGroup[] List of AdminGroup objects
* @throws PropelException
*/
- public function setAdminGroup(AdminGroup $v = null)
+ public function getAdminGroups($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collAdminGroupsPartial && !$this->isNew();
+ if (null === $this->collAdminGroups || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAdminGroups) {
+ // return empty collection
+ $this->initAdminGroups();
+ } else {
+ $collAdminGroups = AdminGroupQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) {
+ $this->initAdminGroups(false);
+
+ foreach($collAdminGroups as $obj) {
+ if (false == $this->collAdminGroups->contains($obj)) {
+ $this->collAdminGroups->append($obj);
+ }
+ }
+
+ $this->collAdminGroupsPartial = true;
+ }
+
+ return $collAdminGroups;
+ }
+
+ if($partial && $this->collAdminGroups) {
+ foreach($this->collAdminGroups as $obj) {
+ if($obj->isNew()) {
+ $collAdminGroups[] = $obj;
+ }
+ }
+ }
+
+ $this->collAdminGroups = $collAdminGroups;
+ $this->collAdminGroupsPartial = false;
+ }
+ }
+
+ return $this->collAdminGroups;
+ }
+
+ /**
+ * Sets a collection of AdminGroup 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 $adminGroups A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null)
+ {
+ $this->adminGroupsScheduledForDeletion = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups);
+
+ foreach ($this->adminGroupsScheduledForDeletion as $adminGroupRemoved) {
+ $adminGroupRemoved->setGroup(null);
+ }
+
+ $this->collAdminGroups = null;
+ foreach ($adminGroups as $adminGroup) {
+ $this->addAdminGroup($adminGroup);
+ }
+
+ $this->collAdminGroups = $adminGroups;
+ $this->collAdminGroupsPartial = false;
+ }
+
+ /**
+ * Returns the number of related AdminGroup objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AdminGroup objects.
+ * @throws PropelException
+ */
+ public function countAdminGroups(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAdminGroupsPartial && !$this->isNew();
+ if (null === $this->collAdminGroups || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAdminGroups) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAdminGroups());
+ }
+ $query = AdminGroupQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getGroupId());
+ return count($this->collAdminGroups);
}
+ }
- $this->aAdminGroup = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setGroup($this);
+ /**
+ * Method called to associate a AdminGroup object to this object
+ * through the AdminGroup foreign key attribute.
+ *
+ * @param AdminGroup $l AdminGroup
+ * @return Group The current object (for fluent API support)
+ */
+ public function addAdminGroup(AdminGroup $l)
+ {
+ if ($this->collAdminGroups === null) {
+ $this->initAdminGroups();
+ $this->collAdminGroupsPartial = true;
+ }
+ if (!$this->collAdminGroups->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAdminGroup($l);
}
-
return $this;
}
-
/**
- * Get the associated AdminGroup object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return AdminGroup The associated AdminGroup object.
- * @throws PropelException
+ * @param AdminGroup $adminGroup The adminGroup object to add.
*/
- public function getAdminGroup(PropelPDO $con = null)
+ protected function doAddAdminGroup($adminGroup)
{
- if ($this->aAdminGroup === null && ($this->id !== null)) {
- $this->aAdminGroup = AdminGroupQuery::create()
- ->filterByGroup($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAdminGroup->setGroup($this);
- }
-
- return $this->aAdminGroup;
+ $this->collAdminGroups[]= $adminGroup;
+ $adminGroup->setGroup($this);
}
/**
- * Declares an association between this object and a GroupDesc object.
+ * @param AdminGroup $adminGroup The adminGroup object to remove.
+ */
+ public function removeAdminGroup($adminGroup)
+ {
+ if ($this->getAdminGroups()->contains($adminGroup)) {
+ $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup));
+ if (null === $this->adminGroupsScheduledForDeletion) {
+ $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups;
+ $this->adminGroupsScheduledForDeletion->clear();
+ }
+ $this->adminGroupsScheduledForDeletion[]= $adminGroup;
+ $adminGroup->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 AdminGroups from storage.
*
- * @param GroupDesc $v
- * @return Group The current object (for fluent API support)
+ * 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|AdminGroup[] List of AdminGroup objects
+ */
+ public function getAdminGroupsJoinAdmin($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AdminGroupQuery::create(null, $criteria);
+ $query->joinWith('Admin', $join_behavior);
+
+ return $this->getAdminGroups($query, $con);
+ }
+
+ /**
+ * 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 setGroupDesc(GroupDesc $v = null)
+ public function getGroupDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getGroupId());
+ return count($this->collGroupDescs);
}
+ }
- $this->aGroupDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setGroup($this);
+ /**
+ * 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;
}
-
/**
- * Get the associated GroupDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return GroupDesc The associated GroupDesc object.
- * @throws PropelException
+ * @param GroupDesc $groupDesc The groupDesc object to add.
*/
- public function getGroupDesc(PropelPDO $con = null)
+ protected function doAddGroupDesc($groupDesc)
{
- if ($this->aGroupDesc === null && ($this->id !== null)) {
- $this->aGroupDesc = GroupDescQuery::create()
- ->filterByGroup($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aGroupDesc->setGroup($this);
- }
-
- return $this->aGroupDesc;
+ $this->collGroupDescs[]= $groupDesc;
+ $groupDesc->setGroup($this);
}
/**
- * Declares an association between this object and a GroupModule object.
+ * @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);
+ }
+ }
+
+ /**
+ * Clears out the collGroupModules collection
*
- * @param GroupModule $v
- * @return Group The current object (for fluent API support)
+ * 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 addGroupModules()
+ */
+ public function clearGroupModules()
+ {
+ $this->collGroupModules = null; // important to set this to null since that means it is uninitialized
+ $this->collGroupModulesPartial = null;
+ }
+
+ /**
+ * reset is the collGroupModules collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialGroupModules($v = true)
+ {
+ $this->collGroupModulesPartial = $v;
+ }
+
+ /**
+ * Initializes the collGroupModules collection.
+ *
+ * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules());
+ * 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 initGroupModules($overrideExisting = true)
+ {
+ if (null !== $this->collGroupModules && !$overrideExisting) {
+ return;
+ }
+ $this->collGroupModules = new PropelObjectCollection();
+ $this->collGroupModules->setModel('GroupModule');
+ }
+
+ /**
+ * Gets an array of GroupModule 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|GroupModule[] List of GroupModule objects
* @throws PropelException
*/
- public function setGroupModule(GroupModule $v = null)
+ public function getGroupModules($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collGroupModulesPartial && !$this->isNew();
+ if (null === $this->collGroupModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupModules) {
+ // return empty collection
+ $this->initGroupModules();
+ } else {
+ $collGroupModules = GroupModuleQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collGroupModulesPartial && count($collGroupModules)) {
+ $this->initGroupModules(false);
+
+ foreach($collGroupModules as $obj) {
+ if (false == $this->collGroupModules->contains($obj)) {
+ $this->collGroupModules->append($obj);
+ }
+ }
+
+ $this->collGroupModulesPartial = true;
+ }
+
+ return $collGroupModules;
+ }
+
+ if($partial && $this->collGroupModules) {
+ foreach($this->collGroupModules as $obj) {
+ if($obj->isNew()) {
+ $collGroupModules[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupModules = $collGroupModules;
+ $this->collGroupModulesPartial = false;
+ }
+ }
+
+ return $this->collGroupModules;
+ }
+
+ /**
+ * Sets a collection of GroupModule 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 $groupModules A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null)
+ {
+ $this->groupModulesScheduledForDeletion = $this->getGroupModules(new Criteria(), $con)->diff($groupModules);
+
+ foreach ($this->groupModulesScheduledForDeletion as $groupModuleRemoved) {
+ $groupModuleRemoved->setGroup(null);
+ }
+
+ $this->collGroupModules = null;
+ foreach ($groupModules as $groupModule) {
+ $this->addGroupModule($groupModule);
+ }
+
+ $this->collGroupModules = $groupModules;
+ $this->collGroupModulesPartial = false;
+ }
+
+ /**
+ * Returns the number of related GroupModule objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related GroupModule objects.
+ * @throws PropelException
+ */
+ public function countGroupModules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collGroupModulesPartial && !$this->isNew();
+ if (null === $this->collGroupModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupModules) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getGroupModules());
+ }
+ $query = GroupModuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getGroupId());
+ return count($this->collGroupModules);
}
+ }
- $this->aGroupModule = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setGroup($this);
+ /**
+ * Method called to associate a GroupModule object to this object
+ * through the GroupModule foreign key attribute.
+ *
+ * @param GroupModule $l GroupModule
+ * @return Group The current object (for fluent API support)
+ */
+ public function addGroupModule(GroupModule $l)
+ {
+ if ($this->collGroupModules === null) {
+ $this->initGroupModules();
+ $this->collGroupModulesPartial = true;
+ }
+ if (!$this->collGroupModules->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupModule($l);
}
-
return $this;
}
-
/**
- * Get the associated GroupModule object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return GroupModule The associated GroupModule object.
- * @throws PropelException
+ * @param GroupModule $groupModule The groupModule object to add.
*/
- public function getGroupModule(PropelPDO $con = null)
+ protected function doAddGroupModule($groupModule)
{
- if ($this->aGroupModule === null && ($this->id !== null)) {
- $this->aGroupModule = GroupModuleQuery::create()
- ->filterByGroup($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aGroupModule->setGroup($this);
- }
-
- return $this->aGroupModule;
+ $this->collGroupModules[]= $groupModule;
+ $groupModule->setGroup($this);
}
/**
- * Declares an association between this object and a GroupResource object.
+ * @param GroupModule $groupModule The groupModule object to remove.
+ */
+ public function removeGroupModule($groupModule)
+ {
+ if ($this->getGroupModules()->contains($groupModule)) {
+ $this->collGroupModules->remove($this->collGroupModules->search($groupModule));
+ if (null === $this->groupModulesScheduledForDeletion) {
+ $this->groupModulesScheduledForDeletion = clone $this->collGroupModules;
+ $this->groupModulesScheduledForDeletion->clear();
+ }
+ $this->groupModulesScheduledForDeletion[]= $groupModule;
+ $groupModule->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 GroupModules from storage.
*
- * @param GroupResource $v
- * @return Group The current object (for fluent API support)
+ * 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|GroupModule[] List of GroupModule objects
+ */
+ public function getGroupModulesJoinModule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = GroupModuleQuery::create(null, $criteria);
+ $query->joinWith('Module', $join_behavior);
+
+ 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 setGroupResource(GroupResource $v = null)
+ public function getGroupResources($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getGroupId());
+ return count($this->collGroupResources);
}
+ }
- $this->aGroupResource = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setGroup($this);
+ /**
+ * 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);
+ }
/**
- * Get the associated GroupResource object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return GroupResource The associated GroupResource object.
- * @throws PropelException
+ * @param GroupResource $groupResource The groupResource object to remove.
*/
- public function getGroupResource(PropelPDO $con = null)
+ public function removeGroupResource($groupResource)
{
- if ($this->aGroupResource === null && ($this->id !== null)) {
- $this->aGroupResource = GroupResourceQuery::create()
- ->filterByGroup($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aGroupResource->setGroup($this);
+ 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);
}
+ }
- return $this->aGroupResource;
+
+ /**
+ * 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);
}
/**
@@ -1322,12 +2110,44 @@ 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) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collGroupResources) {
+ foreach ($this->collGroupResources as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aAdminGroup = null;
- $this->aGroupDesc = null;
- $this->aGroupModule = null;
- $this->aGroupResource = null;
+ 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();
+ }
+ $this->collGroupModules = null;
+ if ($this->collGroupResources instanceof PropelCollection) {
+ $this->collGroupResources->clearIterator();
+ }
+ $this->collGroupResources = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseGroupDesc.php b/core/lib/Thelia/Model/om/BaseGroupDesc.php
index 47428bbdc..70c7ebc38 100644
--- a/core/lib/Thelia/Model/om/BaseGroupDesc.php
+++ b/core/lib/Thelia/Model/om/BaseGroupDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Group;
use Thelia\Model\GroupDesc;
@@ -98,9 +96,9 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Group one-to-one related Group object
+ * @var Group
*/
- protected $singleGroup;
+ protected $aGroup;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $groupsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -294,6 +286,10 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = GroupDescPeer::GROUP_ID;
}
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
return $this;
} // setGroupId()
@@ -499,6 +495,9 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
} // ensureConsistency
/**
@@ -538,8 +537,7 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleGroup = null;
-
+ $this->aGroup = null;
} // if (deep)
}
@@ -653,6 +651,18 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
+ $affectedRows += $this->aGroup->save($con);
+ }
+ $this->setGroup($this->aGroup);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -664,21 +674,6 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->groupsScheduledForDeletion !== null) {
- if (!$this->groupsScheduledForDeletion->isEmpty()) {
- GroupQuery::create()
- ->filterByPrimaryKeys($this->groupsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->groupsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleGroup !== null) {
- if (!$this->singleGroup->isDeleted()) {
- $affectedRows += $this->singleGroup->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -847,17 +842,23 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if (!$this->aGroup->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures());
+ }
+ }
+
+
if (($retval = GroupDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleGroup !== null) {
- if (!$this->singleGroup->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleGroup->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -956,8 +957,8 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleGroup) {
- $result['Group'] = $this->singleGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1146,11 +1147,6 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getGroup();
- if ($relObj) {
- $copyObj->setGroup($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1201,55 +1197,57 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Group object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Group object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Group
- * @throws PropelException
- */
- public function getGroup(PropelPDO $con = null)
- {
-
- if ($this->singleGroup === null && !$this->isNew()) {
- $this->singleGroup = GroupQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleGroup;
- }
-
- /**
- * Sets a single Group object as related to this object by a one-to-one relationship.
- *
- * @param Group $v Group
+ * @param Group $v
* @return GroupDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setGroup(Group $v = null)
{
- $this->singleGroup = $v;
-
- // Make sure that that the passed-in Group isn't already associated with this object
- if ($v !== null && $v->getGroupDesc() === null) {
- $v->setGroupDesc($this);
+ if ($v === null) {
+ $this->setGroupId(NULL);
+ } else {
+ $this->setGroupId($v->getId());
}
+ $this->aGroup = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Group object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Group object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Group The associated Group object.
+ * @throws PropelException
+ */
+ public function getGroup(PropelPDO $con = null)
+ {
+ if ($this->aGroup === null && ($this->group_id !== null)) {
+ $this->aGroup = GroupQuery::create()->findPk($this->group_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->aGroup->addGroupDescs($this);
+ */
+ }
+
+ return $this->aGroup;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1283,15 +1281,9 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleGroup) {
- $this->singleGroup->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleGroup instanceof PropelCollection) {
- $this->singleGroup->clearIterator();
- }
- $this->singleGroup = null;
+ $this->aGroup = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseGroupDescPeer.php b/core/lib/Thelia/Model/om/BaseGroupDescPeer.php
index bc5d67f2e..968d5789c 100644
--- a/core/lib/Thelia/Model/om/BaseGroupDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseGroupDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseGroupDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'group_desc';
@@ -398,9 +398,6 @@ abstract class BaseGroupDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in GroupPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- GroupPeer::clearInstancePool();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseGroupDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Group table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinGroup(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupDescPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of GroupDesc objects pre-filled with their Group objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME);
+ }
+
+ GroupDescPeer::addSelectColumns($criteria);
+ $startcol = GroupDescPeer::NUM_HYDRATE_COLUMNS;
+ GroupPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(GroupDescPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = GroupDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (GroupDesc) to $obj2 (Group)
+ $obj2->addGroupDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupDescPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of GroupDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME);
+ }
+
+ GroupDescPeer::addSelectColumns($criteria);
+ $startcol2 = GroupDescPeer::NUM_HYDRATE_COLUMNS;
+
+ GroupPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(GroupDescPeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = GroupDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Group rows
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (GroupDesc) to the collection in $obj2 (Group)
+ $obj2->addGroupDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -626,7 +861,6 @@ abstract class BaseGroupDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += GroupDescPeer::doOnDeleteCascade(new Criteria(GroupDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(GroupDescPeer::TABLE_NAME, $con, GroupDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -660,14 +894,24 @@ abstract class BaseGroupDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ GroupDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof GroupDesc) { // it's a model object
+ // invalidate the cache for this single object
+ GroupDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(GroupDescPeer::DATABASE_NAME);
$criteria->add(GroupDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ GroupDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -680,23 +924,6 @@ abstract class BaseGroupDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += GroupDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- GroupDescPeer::clearInstancePool();
- } elseif ($values instanceof GroupDesc) { // it's a model object
- GroupDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- GroupDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
GroupDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -708,39 +935,6 @@ abstract class BaseGroupDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = GroupDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Group objects
- $criteria = new Criteria(GroupPeer::DATABASE_NAME);
-
- $criteria->add(GroupPeer::ID, $obj->getGroupId());
- $affectedRows += GroupPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given GroupDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseGroupDescQuery.php b/core/lib/Thelia/Model/om/BaseGroupDescQuery.php
index c1b704bb5..7976f5572 100644
--- a/core/lib/Thelia/Model/om/BaseGroupDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseGroupDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseGroupDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\GroupDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\GroupDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -283,6 +283,8 @@ abstract class BaseGroupDescQuery extends ModelCriteria
* $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
*
*
+ * @see filterByGroup()
+ *
* @param mixed $groupId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +521,7 @@ abstract class BaseGroupDescQuery extends ModelCriteria
/**
* Filter the query by a related Group object
*
- * @param Group|PropelObjectCollection $group the related object to use as filter
+ * @param Group|PropelObjectCollection $group The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return GroupDescQuery The current query, for fluid interface
@@ -531,10 +533,12 @@ abstract class BaseGroupDescQuery extends ModelCriteria
return $this
->addUsingAlias(GroupDescPeer::GROUP_ID, $group->getId(), $comparison);
} elseif ($group instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useGroupQuery()
- ->filterByPrimaryKeys($group->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(GroupDescPeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseGroupModule.php b/core/lib/Thelia/Model/om/BaseGroupModule.php
index b0fadf98a..ee1e968de 100644
--- a/core/lib/Thelia/Model/om/BaseGroupModule.php
+++ b/core/lib/Thelia/Model/om/BaseGroupModule.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Group;
use Thelia\Model\GroupModule;
@@ -89,14 +87,14 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Group one-to-one related Group object
+ * @var Group
*/
- protected $singleGroup;
+ protected $aGroup;
/**
- * @var Module one-to-one related Module object
+ * @var Module
*/
- protected $singleModule;
+ protected $aModule;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -112,18 +110,6 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $groupsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $modulesScheduledForDeletion = null;
-
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
@@ -297,6 +283,10 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
$this->modifiedColumns[] = GroupModulePeer::GROUP_ID;
}
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
return $this;
} // setGroupId()
@@ -318,6 +308,10 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
$this->modifiedColumns[] = GroupModulePeer::MODULE_ID;
}
+ if ($this->aModule !== null && $this->aModule->getId() !== $v) {
+ $this->aModule = null;
+ }
+
return $this;
} // setModuleId()
@@ -462,6 +456,12 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
+ if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) {
+ $this->aModule = null;
+ }
} // ensureConsistency
/**
@@ -501,10 +501,8 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleGroup = null;
-
- $this->singleModule = null;
-
+ $this->aGroup = null;
+ $this->aModule = null;
} // if (deep)
}
@@ -618,6 +616,25 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
+ $affectedRows += $this->aGroup->save($con);
+ }
+ $this->setGroup($this->aGroup);
+ }
+
+ if ($this->aModule !== null) {
+ if ($this->aModule->isModified() || $this->aModule->isNew()) {
+ $affectedRows += $this->aModule->save($con);
+ }
+ $this->setModule($this->aModule);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -629,36 +646,6 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->groupsScheduledForDeletion !== null) {
- if (!$this->groupsScheduledForDeletion->isEmpty()) {
- GroupQuery::create()
- ->filterByPrimaryKeys($this->groupsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->groupsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleGroup !== null) {
- if (!$this->singleGroup->isDeleted()) {
- $affectedRows += $this->singleGroup->save($con);
- }
- }
-
- if ($this->modulesScheduledForDeletion !== null) {
- if (!$this->modulesScheduledForDeletion->isEmpty()) {
- ModuleQuery::create()
- ->filterByPrimaryKeys($this->modulesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->modulesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleModule !== null) {
- if (!$this->singleModule->isDeleted()) {
- $affectedRows += $this->singleModule->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -826,23 +813,29 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if (!$this->aGroup->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures());
+ }
+ }
+
+ if ($this->aModule !== null) {
+ if (!$this->aModule->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aModule->getValidationFailures());
+ }
+ }
+
+
if (($retval = GroupModulePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleGroup !== null) {
- if (!$this->singleGroup->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleGroup->getValidationFailures());
- }
- }
-
- if ($this->singleModule !== null) {
- if (!$this->singleModule->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleModule->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -933,11 +926,11 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
$keys[5] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleGroup) {
- $result['Group'] = $this->singleGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleModule) {
- $result['Module'] = $this->singleModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aModule) {
+ $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1114,16 +1107,6 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getGroup();
- if ($relObj) {
- $copyObj->setGroup($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getModule();
- if ($relObj) {
- $copyObj->setModule($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1174,91 +1157,108 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Group object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Group object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Group
- * @throws PropelException
- */
- public function getGroup(PropelPDO $con = null)
- {
-
- if ($this->singleGroup === null && !$this->isNew()) {
- $this->singleGroup = GroupQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleGroup;
- }
-
- /**
- * Sets a single Group object as related to this object by a one-to-one relationship.
- *
- * @param Group $v Group
+ * @param Group $v
* @return GroupModule The current object (for fluent API support)
* @throws PropelException
*/
public function setGroup(Group $v = null)
{
- $this->singleGroup = $v;
-
- // Make sure that that the passed-in Group isn't already associated with this object
- if ($v !== null && $v->getGroupModule() === null) {
- $v->setGroupModule($this);
+ if ($v === null) {
+ $this->setGroupId(NULL);
+ } else {
+ $this->setGroupId($v->getId());
}
+ $this->aGroup = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Group object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupModule($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Module object, which is related to this object by a one-to-one relationship.
+ * Get the associated Group object
*
- * @param PropelPDO $con optional connection object
- * @return Module
+ * @param PropelPDO $con Optional Connection object.
+ * @return Group The associated Group object.
* @throws PropelException
*/
- public function getModule(PropelPDO $con = null)
+ public function getGroup(PropelPDO $con = null)
{
-
- if ($this->singleModule === null && !$this->isNew()) {
- $this->singleModule = ModuleQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aGroup === null && ($this->group_id !== null)) {
+ $this->aGroup = GroupQuery::create()->findPk($this->group_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->aGroup->addGroupModules($this);
+ */
}
- return $this->singleModule;
+ return $this->aGroup;
}
/**
- * Sets a single Module object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Module object.
*
- * @param Module $v Module
+ * @param Module $v
* @return GroupModule The current object (for fluent API support)
* @throws PropelException
*/
public function setModule(Module $v = null)
{
- $this->singleModule = $v;
-
- // Make sure that that the passed-in Module isn't already associated with this object
- if ($v !== null && $v->getGroupModule() === null) {
- $v->setGroupModule($this);
+ if ($v === null) {
+ $this->setModuleId(NULL);
+ } else {
+ $this->setModuleId($v->getId());
}
+ $this->aModule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Module object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupModule($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Module object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Module The associated Module object.
+ * @throws PropelException
+ */
+ public function getModule(PropelPDO $con = null)
+ {
+ if ($this->aModule === null && ($this->module_id !== null)) {
+ $this->aModule = ModuleQuery::create()->findPk($this->module_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->aModule->addGroupModules($this);
+ */
+ }
+
+ return $this->aModule;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1291,22 +1291,10 @@ abstract class BaseGroupModule extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleGroup) {
- $this->singleGroup->clearAllReferences($deep);
- }
- if ($this->singleModule) {
- $this->singleModule->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleGroup instanceof PropelCollection) {
- $this->singleGroup->clearIterator();
- }
- $this->singleGroup = null;
- if ($this->singleModule instanceof PropelCollection) {
- $this->singleModule->clearIterator();
- }
- $this->singleModule = null;
+ $this->aGroup = null;
+ $this->aModule = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseGroupModulePeer.php b/core/lib/Thelia/Model/om/BaseGroupModulePeer.php
index fc0aa46f6..4b01ddc66 100644
--- a/core/lib/Thelia/Model/om/BaseGroupModulePeer.php
+++ b/core/lib/Thelia/Model/om/BaseGroupModulePeer.php
@@ -26,7 +26,7 @@ abstract class BaseGroupModulePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'group_module';
@@ -389,12 +389,6 @@ abstract class BaseGroupModulePeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in GroupPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- GroupPeer::clearInstancePool();
- // Invalidate objects in ModulePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ModulePeer::clearInstancePool();
}
/**
@@ -491,6 +485,637 @@ abstract class BaseGroupModulePeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Group table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinGroup(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupModulePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Module table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinModule(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupModulePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of GroupModule objects pre-filled with their Group objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupModule objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+ }
+
+ GroupModulePeer::addSelectColumns($criteria);
+ $startcol = GroupModulePeer::NUM_HYDRATE_COLUMNS;
+ GroupPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = GroupModulePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupModulePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (GroupModule) to $obj2 (Group)
+ $obj2->addGroupModule($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of GroupModule objects pre-filled with their Module objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupModule objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+ }
+
+ GroupModulePeer::addSelectColumns($criteria);
+ $startcol = GroupModulePeer::NUM_HYDRATE_COLUMNS;
+ ModulePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = GroupModulePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupModulePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ModulePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ModulePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ModulePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (GroupModule) to $obj2 (Module)
+ $obj2->addGroupModule($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupModulePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of GroupModule objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupModule objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+ }
+
+ GroupModulePeer::addSelectColumns($criteria);
+ $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS;
+
+ GroupPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
+
+ ModulePeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ModulePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = GroupModulePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupModulePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Group rows
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (GroupModule) to the collection in $obj2 (Group)
+ $obj2->addGroupModule($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Module rows
+
+ $key3 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ModulePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ModulePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ModulePeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (GroupModule) to the collection in $obj3 (Module)
+ $obj3->addGroupModule($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Group table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptGroup(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupModulePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Module table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptModule(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupModulePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of GroupModule objects pre-filled with all related objects except Group.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupModule objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+ }
+
+ GroupModulePeer::addSelectColumns($criteria);
+ $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS;
+
+ ModulePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ModulePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = GroupModulePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupModulePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Module rows
+
+ $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ModulePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ModulePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ModulePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (GroupModule) to the collection in $obj2 (Module)
+ $obj2->addGroupModule($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of GroupModule objects pre-filled with all related objects except Module.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupModule objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+ }
+
+ GroupModulePeer::addSelectColumns($criteria);
+ $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS;
+
+ GroupPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = GroupModulePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupModulePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Group rows
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (GroupModule) to the collection in $obj2 (Group)
+ $obj2->addGroupModule($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -624,7 +1249,6 @@ abstract class BaseGroupModulePeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += GroupModulePeer::doOnDeleteCascade(new Criteria(GroupModulePeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(GroupModulePeer::TABLE_NAME, $con, GroupModulePeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -658,14 +1282,24 @@ abstract class BaseGroupModulePeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ GroupModulePeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof GroupModule) { // it's a model object
+ // invalidate the cache for this single object
+ GroupModulePeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(GroupModulePeer::DATABASE_NAME);
$criteria->add(GroupModulePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ GroupModulePeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -678,23 +1312,6 @@ abstract class BaseGroupModulePeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += GroupModulePeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- GroupModulePeer::clearInstancePool();
- } elseif ($values instanceof GroupModule) { // it's a model object
- GroupModulePeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- GroupModulePeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
GroupModulePeer::clearRelatedInstancePool();
$con->commit();
@@ -706,45 +1323,6 @@ abstract class BaseGroupModulePeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = GroupModulePeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Group objects
- $criteria = new Criteria(GroupPeer::DATABASE_NAME);
-
- $criteria->add(GroupPeer::ID, $obj->getGroupId());
- $affectedRows += GroupPeer::doDelete($criteria, $con);
-
- // delete related Module objects
- $criteria = new Criteria(ModulePeer::DATABASE_NAME);
-
- $criteria->add(ModulePeer::ID, $obj->getModuleId());
- $affectedRows += ModulePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given GroupModule object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php
index b5c9c84ea..d43848e11 100644
--- a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php
+++ b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php
@@ -77,7 +77,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\GroupModule', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\GroupModule', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -280,6 +280,8 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
* $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
*
*
+ * @see filterByGroup()
+ *
* @param mixed $groupId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -321,6 +323,8 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
* $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
*
*
+ * @see filterByModule()
+ *
* @param mixed $moduleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -482,7 +486,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
/**
* Filter the query by a related Group object
*
- * @param Group|PropelObjectCollection $group the related object to use as filter
+ * @param Group|PropelObjectCollection $group The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return GroupModuleQuery The current query, for fluid interface
@@ -494,10 +498,12 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
return $this
->addUsingAlias(GroupModulePeer::GROUP_ID, $group->getId(), $comparison);
} elseif ($group instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useGroupQuery()
- ->filterByPrimaryKeys($group->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(GroupModulePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
}
@@ -556,7 +562,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
/**
* Filter the query by a related Module object
*
- * @param Module|PropelObjectCollection $module the related object to use as filter
+ * @param Module|PropelObjectCollection $module The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return GroupModuleQuery The current query, for fluid interface
@@ -568,10 +574,12 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
return $this
->addUsingAlias(GroupModulePeer::MODULE_ID, $module->getId(), $comparison);
} elseif ($module instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useModuleQuery()
- ->filterByPrimaryKeys($module->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(GroupModulePeer::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByModule() only accepts arguments of type Module or PropelCollection');
}
@@ -585,7 +593,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
*
* @return GroupModuleQuery The current query, for fluid interface
*/
- public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Module');
@@ -620,7 +628,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria
*
* @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query
*/
- public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinModule($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseGroupPeer.php b/core/lib/Thelia/Model/om/BaseGroupPeer.php
index a345653ad..ce32ce038 100644
--- a/core/lib/Thelia/Model/om/BaseGroupPeer.php
+++ b/core/lib/Thelia/Model/om/BaseGroupPeer.php
@@ -28,7 +28,7 @@ abstract class BaseGroupPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'group';
@@ -381,6 +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,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ GroupModulePeer::clearInstancePool();
+ // Invalidate objects in GroupResourcePeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ GroupResourcePeer::clearInstancePool();
}
/**
@@ -477,1385 +489,6 @@ abstract class BaseGroupPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related AdminGroup table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAdminGroup(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinGroupDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupModule table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinGroupModule(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupResource table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinGroupResource(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Group objects pre-filled with their AdminGroup objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAdminGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol = GroupPeer::NUM_HYDRATE_COLUMNS;
- AdminGroupPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AdminGroupPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AdminGroupPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AdminGroupPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Group) to $obj2 (AdminGroup)
- // one to one relationship
- $obj1->setAdminGroup($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Group objects pre-filled with their GroupDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinGroupDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol = GroupPeer::NUM_HYDRATE_COLUMNS;
- GroupDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = GroupDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = GroupDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- GroupDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Group) to $obj2 (GroupDesc)
- // one to one relationship
- $obj1->setGroupDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Group objects pre-filled with their GroupModule objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinGroupModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol = GroupPeer::NUM_HYDRATE_COLUMNS;
- GroupModulePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = GroupModulePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupModulePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- GroupModulePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Group) to $obj2 (GroupModule)
- // one to one relationship
- $obj1->setGroupModule($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Group objects pre-filled with their GroupResource objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinGroupResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol = GroupPeer::NUM_HYDRATE_COLUMNS;
- GroupResourcePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = GroupResourcePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupResourcePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- GroupResourcePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Group) to $obj2 (GroupResource)
- // one to one relationship
- $obj1->setGroupResource($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Group objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol2 = GroupPeer::NUM_HYDRATE_COLUMNS;
-
- AdminGroupPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AdminGroupPeer::NUM_HYDRATE_COLUMNS;
-
- GroupDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + GroupDescPeer::NUM_HYDRATE_COLUMNS;
-
- GroupModulePeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + GroupModulePeer::NUM_HYDRATE_COLUMNS;
-
- GroupResourcePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + GroupResourcePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AdminGroup rows
-
- $key2 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AdminGroupPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AdminGroupPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AdminGroupPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Group) to the collection in $obj2 (AdminGroup)
- $obj1->setAdminGroup($obj2);
- } // if joined row not null
-
- // Add objects for joined GroupDesc rows
-
- $key3 = GroupDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = GroupDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = GroupDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- GroupDescPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Group) to the collection in $obj3 (GroupDesc)
- $obj1->setGroupDesc($obj3);
- } // if joined row not null
-
- // Add objects for joined GroupModule rows
-
- $key4 = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = GroupModulePeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = GroupModulePeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- GroupModulePeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (Group) to the collection in $obj4 (GroupModule)
- $obj1->setGroupModule($obj4);
- } // if joined row not null
-
- // Add objects for joined GroupResource rows
-
- $key5 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = GroupResourcePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = GroupResourcePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- GroupResourcePeer::addInstanceToPool($obj5, $key5);
- } // if obj5 loaded
-
- // Add the $obj1 (Group) to the collection in $obj5 (GroupResource)
- $obj1->setGroupResource($obj5);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related AdminGroup table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAdminGroup(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptGroupDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupModule table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptGroupModule(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupResource table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptGroupResource(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- GroupPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Group objects pre-filled with all related objects except AdminGroup.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAdminGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol2 = GroupPeer::NUM_HYDRATE_COLUMNS;
-
- GroupDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + GroupDescPeer::NUM_HYDRATE_COLUMNS;
-
- GroupModulePeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + GroupModulePeer::NUM_HYDRATE_COLUMNS;
-
- GroupResourcePeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + GroupResourcePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined GroupDesc rows
-
- $key2 = GroupDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = GroupDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- GroupDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj2 (GroupDesc)
- $obj1->setGroupDesc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined GroupModule rows
-
- $key3 = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = GroupModulePeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = GroupModulePeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- GroupModulePeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj3 (GroupModule)
- $obj1->setGroupModule($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined GroupResource rows
-
- $key4 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = GroupResourcePeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = GroupResourcePeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- GroupResourcePeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj4 (GroupResource)
- $obj1->setGroupResource($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Group objects pre-filled with all related objects except GroupDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptGroupDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol2 = GroupPeer::NUM_HYDRATE_COLUMNS;
-
- AdminGroupPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AdminGroupPeer::NUM_HYDRATE_COLUMNS;
-
- GroupModulePeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + GroupModulePeer::NUM_HYDRATE_COLUMNS;
-
- GroupResourcePeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + GroupResourcePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AdminGroup rows
-
- $key2 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AdminGroupPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AdminGroupPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AdminGroupPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj2 (AdminGroup)
- $obj1->setAdminGroup($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined GroupModule rows
-
- $key3 = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = GroupModulePeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = GroupModulePeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- GroupModulePeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj3 (GroupModule)
- $obj1->setGroupModule($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined GroupResource rows
-
- $key4 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = GroupResourcePeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = GroupResourcePeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- GroupResourcePeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj4 (GroupResource)
- $obj1->setGroupResource($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Group objects pre-filled with all related objects except GroupModule.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptGroupModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol2 = GroupPeer::NUM_HYDRATE_COLUMNS;
-
- AdminGroupPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AdminGroupPeer::NUM_HYDRATE_COLUMNS;
-
- GroupDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + GroupDescPeer::NUM_HYDRATE_COLUMNS;
-
- GroupResourcePeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + GroupResourcePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupResourcePeer::GROUP_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AdminGroup rows
-
- $key2 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AdminGroupPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AdminGroupPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AdminGroupPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj2 (AdminGroup)
- $obj1->setAdminGroup($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined GroupDesc rows
-
- $key3 = GroupDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = GroupDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = GroupDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- GroupDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj3 (GroupDesc)
- $obj1->setGroupDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined GroupResource rows
-
- $key4 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = GroupResourcePeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = GroupResourcePeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- GroupResourcePeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj4 (GroupResource)
- $obj1->setGroupResource($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Group objects pre-filled with all related objects except GroupResource.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Group objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptGroupResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(GroupPeer::DATABASE_NAME);
- }
-
- GroupPeer::addSelectColumns($criteria);
- $startcol2 = GroupPeer::NUM_HYDRATE_COLUMNS;
-
- AdminGroupPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AdminGroupPeer::NUM_HYDRATE_COLUMNS;
-
- GroupDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + GroupDescPeer::NUM_HYDRATE_COLUMNS;
-
- GroupModulePeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + GroupModulePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(GroupPeer::ID, AdminGroupPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupDescPeer::GROUP_ID, $join_behavior);
-
- $criteria->addJoin(GroupPeer::ID, GroupModulePeer::GROUP_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = GroupPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = GroupPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- GroupPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined AdminGroup rows
-
- $key2 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AdminGroupPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AdminGroupPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AdminGroupPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj2 (AdminGroup)
- $obj1->setAdminGroup($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined GroupDesc rows
-
- $key3 = GroupDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = GroupDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = GroupDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- GroupDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj3 (GroupDesc)
- $obj1->setGroupDesc($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined GroupModule rows
-
- $key4 = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = GroupModulePeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = GroupModulePeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- GroupModulePeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Group) to the collection in $obj4 (GroupModule)
- $obj1->setGroupModule($obj4);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseGroupQuery.php b/core/lib/Thelia/Model/om/BaseGroupQuery.php
index f46908d6c..a6f5c29ad 100644
--- a/core/lib/Thelia/Model/om/BaseGroupQuery.php
+++ b/core/lib/Thelia/Model/om/BaseGroupQuery.php
@@ -79,7 +79,7 @@ abstract class BaseGroupQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Group', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Group', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -255,14 +255,6 @@ abstract class BaseGroupQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAdminGroup()
- *
- * @see filterByGroupDesc()
- *
- * @see filterByGroupModule()
- *
- * @see filterByGroupResource()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -398,7 +390,7 @@ abstract class BaseGroupQuery extends ModelCriteria
/**
* Filter the query by a related AdminGroup object
*
- * @param AdminGroup|PropelObjectCollection $adminGroup The related object(s) 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
@@ -410,12 +402,10 @@ abstract class BaseGroupQuery extends ModelCriteria
return $this
->addUsingAlias(GroupPeer::ID, $adminGroup->getGroupId(), $comparison);
} elseif ($adminGroup instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(GroupPeer::ID, $adminGroup->toKeyValue('PrimaryKey', 'GroupId'), $comparison);
+ ->useAdminGroupQuery()
+ ->filterByPrimaryKeys($adminGroup->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection');
}
@@ -429,7 +419,7 @@ abstract class BaseGroupQuery extends ModelCriteria
*
* @return GroupQuery The current query, for fluid interface
*/
- public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinAdminGroup($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('AdminGroup');
@@ -464,7 +454,7 @@ abstract class BaseGroupQuery extends ModelCriteria
*
* @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query
*/
- public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinAdminGroup($relationAlias, $joinType)
@@ -474,7 +464,7 @@ abstract class BaseGroupQuery extends ModelCriteria
/**
* Filter the query by a related GroupDesc object
*
- * @param GroupDesc|PropelObjectCollection $groupDesc The related object(s) to use as filter
+ * @param GroupDesc|PropelObjectCollection $groupDesc 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
@@ -486,12 +476,10 @@ abstract class BaseGroupQuery extends ModelCriteria
return $this
->addUsingAlias(GroupPeer::ID, $groupDesc->getGroupId(), $comparison);
} elseif ($groupDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(GroupPeer::ID, $groupDesc->toKeyValue('PrimaryKey', 'GroupId'), $comparison);
+ ->useGroupDescQuery()
+ ->filterByPrimaryKeys($groupDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByGroupDesc() only accepts arguments of type GroupDesc or PropelCollection');
}
@@ -550,7 +538,7 @@ abstract class BaseGroupQuery extends ModelCriteria
/**
* Filter the query by a related GroupModule object
*
- * @param GroupModule|PropelObjectCollection $groupModule The related object(s) to use as filter
+ * @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
@@ -562,12 +550,10 @@ abstract class BaseGroupQuery extends ModelCriteria
return $this
->addUsingAlias(GroupPeer::ID, $groupModule->getGroupId(), $comparison);
} elseif ($groupModule instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(GroupPeer::ID, $groupModule->toKeyValue('PrimaryKey', 'GroupId'), $comparison);
+ ->useGroupModuleQuery()
+ ->filterByPrimaryKeys($groupModule->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection');
}
@@ -626,7 +612,7 @@ abstract class BaseGroupQuery extends ModelCriteria
/**
* Filter the query by a related GroupResource object
*
- * @param GroupResource|PropelObjectCollection $groupResource The related object(s) to use as filter
+ * @param GroupResource|PropelObjectCollection $groupResource the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return GroupQuery The current query, for fluid interface
@@ -638,12 +624,10 @@ abstract class BaseGroupQuery extends ModelCriteria
return $this
->addUsingAlias(GroupPeer::ID, $groupResource->getGroupId(), $comparison);
} elseif ($groupResource instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(GroupPeer::ID, $groupResource->toKeyValue('PrimaryKey', 'GroupId'), $comparison);
+ ->useGroupResourceQuery()
+ ->filterByPrimaryKeys($groupResource->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseGroupResource.php b/core/lib/Thelia/Model/om/BaseGroupResource.php
index d95168512..19e6b6d32 100644
--- a/core/lib/Thelia/Model/om/BaseGroupResource.php
+++ b/core/lib/Thelia/Model/om/BaseGroupResource.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Group;
use Thelia\Model\GroupQuery;
@@ -96,14 +94,14 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Group one-to-one related Group object
+ * @var Group
*/
- protected $singleGroup;
+ protected $aGroup;
/**
- * @var Resource one-to-one related Resource object
+ * @var Resource
*/
- protected $singleResource;
+ protected $aResource;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -119,18 +117,6 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $groupsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $resourcesScheduledForDeletion = null;
-
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
@@ -315,6 +301,10 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
$this->modifiedColumns[] = GroupResourcePeer::GROUP_ID;
}
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
return $this;
} // setGroupId()
@@ -336,6 +326,10 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
$this->modifiedColumns[] = GroupResourcePeer::RESOURCE_ID;
}
+ if ($this->aResource !== null && $this->aResource->getId() !== $v) {
+ $this->aResource = null;
+ }
+
return $this;
} // setResourceId()
@@ -506,6 +500,12 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
+ if ($this->aResource !== null && $this->resource_id !== $this->aResource->getId()) {
+ $this->aResource = null;
+ }
} // ensureConsistency
/**
@@ -545,10 +545,8 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleGroup = null;
-
- $this->singleResource = null;
-
+ $this->aGroup = null;
+ $this->aResource = null;
} // if (deep)
}
@@ -662,6 +660,25 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
+ $affectedRows += $this->aGroup->save($con);
+ }
+ $this->setGroup($this->aGroup);
+ }
+
+ if ($this->aResource !== null) {
+ if ($this->aResource->isModified() || $this->aResource->isNew()) {
+ $affectedRows += $this->aResource->save($con);
+ }
+ $this->setResource($this->aResource);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -673,36 +690,6 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->groupsScheduledForDeletion !== null) {
- if (!$this->groupsScheduledForDeletion->isEmpty()) {
- GroupQuery::create()
- ->filterByPrimaryKeys($this->groupsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->groupsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleGroup !== null) {
- if (!$this->singleGroup->isDeleted()) {
- $affectedRows += $this->singleGroup->save($con);
- }
- }
-
- if ($this->resourcesScheduledForDeletion !== null) {
- if (!$this->resourcesScheduledForDeletion->isEmpty()) {
- ResourceQuery::create()
- ->filterByPrimaryKeys($this->resourcesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->resourcesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleResource !== null) {
- if (!$this->singleResource->isDeleted()) {
- $affectedRows += $this->singleResource->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -876,23 +863,29 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if (!$this->aGroup->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures());
+ }
+ }
+
+ if ($this->aResource !== null) {
+ if (!$this->aResource->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aResource->getValidationFailures());
+ }
+ }
+
+
if (($retval = GroupResourcePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleGroup !== null) {
- if (!$this->singleGroup->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleGroup->getValidationFailures());
- }
- }
-
- if ($this->singleResource !== null) {
- if (!$this->singleResource->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleResource->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -987,11 +980,11 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleGroup) {
- $result['Group'] = $this->singleGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleResource) {
- $result['Resource'] = $this->singleResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aResource) {
+ $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1174,16 +1167,6 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getGroup();
- if ($relObj) {
- $copyObj->setGroup($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getResource();
- if ($relObj) {
- $copyObj->setResource($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1234,91 +1217,108 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Group object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Group object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Group
- * @throws PropelException
- */
- public function getGroup(PropelPDO $con = null)
- {
-
- if ($this->singleGroup === null && !$this->isNew()) {
- $this->singleGroup = GroupQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleGroup;
- }
-
- /**
- * Sets a single Group object as related to this object by a one-to-one relationship.
- *
- * @param Group $v Group
+ * @param Group $v
* @return GroupResource The current object (for fluent API support)
* @throws PropelException
*/
public function setGroup(Group $v = null)
{
- $this->singleGroup = $v;
-
- // Make sure that that the passed-in Group isn't already associated with this object
- if ($v !== null && $v->getGroupResource() === null) {
- $v->setGroupResource($this);
+ if ($v === null) {
+ $this->setGroupId(NULL);
+ } else {
+ $this->setGroupId($v->getId());
}
+ $this->aGroup = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Group object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupResource($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Resource object, which is related to this object by a one-to-one relationship.
+ * Get the associated Group object
*
- * @param PropelPDO $con optional connection object
- * @return Resource
+ * @param PropelPDO $con Optional Connection object.
+ * @return Group The associated Group object.
* @throws PropelException
*/
- public function getResource(PropelPDO $con = null)
+ public function getGroup(PropelPDO $con = null)
{
-
- if ($this->singleResource === null && !$this->isNew()) {
- $this->singleResource = ResourceQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aGroup === null && ($this->group_id !== null)) {
+ $this->aGroup = GroupQuery::create()->findPk($this->group_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->aGroup->addGroupResources($this);
+ */
}
- return $this->singleResource;
+ return $this->aGroup;
}
/**
- * Sets a single Resource object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Resource object.
*
- * @param Resource $v Resource
+ * @param Resource $v
* @return GroupResource The current object (for fluent API support)
* @throws PropelException
*/
public function setResource(Resource $v = null)
{
- $this->singleResource = $v;
-
- // Make sure that that the passed-in Resource isn't already associated with this object
- if ($v !== null && $v->getGroupResource() === null) {
- $v->setGroupResource($this);
+ if ($v === null) {
+ $this->setResourceId(NULL);
+ } else {
+ $this->setResourceId($v->getId());
}
+ $this->aResource = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Resource object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupResource($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Resource object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Resource The associated Resource object.
+ * @throws PropelException
+ */
+ public function getResource(PropelPDO $con = null)
+ {
+ if ($this->aResource === null && ($this->resource_id !== null)) {
+ $this->aResource = ResourceQuery::create()->findPk($this->resource_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->aResource->addGroupResources($this);
+ */
+ }
+
+ return $this->aResource;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1352,22 +1352,10 @@ abstract class BaseGroupResource extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleGroup) {
- $this->singleGroup->clearAllReferences($deep);
- }
- if ($this->singleResource) {
- $this->singleResource->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleGroup instanceof PropelCollection) {
- $this->singleGroup->clearIterator();
- }
- $this->singleGroup = null;
- if ($this->singleResource instanceof PropelCollection) {
- $this->singleResource->clearIterator();
- }
- $this->singleResource = null;
+ $this->aGroup = null;
+ $this->aResource = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php b/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php
index f00d2db7a..bfecc6147 100644
--- a/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php
+++ b/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php
@@ -26,7 +26,7 @@ abstract class BaseGroupResourcePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'group_resource';
@@ -394,12 +394,6 @@ abstract class BaseGroupResourcePeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in GroupPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- GroupPeer::clearInstancePool();
- // Invalidate objects in ResourcePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ResourcePeer::clearInstancePool();
}
/**
@@ -496,6 +490,637 @@ abstract class BaseGroupResourcePeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Group table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinGroup(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupResourcePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Resource table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinResource(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupResourcePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of GroupResource objects pre-filled with their Group objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupResource objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+ }
+
+ GroupResourcePeer::addSelectColumns($criteria);
+ $startcol = GroupResourcePeer::NUM_HYDRATE_COLUMNS;
+ GroupPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = GroupResourcePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupResourcePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (GroupResource) to $obj2 (Group)
+ $obj2->addGroupResource($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of GroupResource objects pre-filled with their Resource objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupResource objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+ }
+
+ GroupResourcePeer::addSelectColumns($criteria);
+ $startcol = GroupResourcePeer::NUM_HYDRATE_COLUMNS;
+ ResourcePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = GroupResourcePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupResourcePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ResourcePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ResourcePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ResourcePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (GroupResource) to $obj2 (Resource)
+ $obj2->addGroupResource($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupResourcePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of GroupResource objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupResource objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+ }
+
+ GroupResourcePeer::addSelectColumns($criteria);
+ $startcol2 = GroupResourcePeer::NUM_HYDRATE_COLUMNS;
+
+ GroupPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
+
+ ResourcePeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ResourcePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = GroupResourcePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupResourcePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Group rows
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (GroupResource) to the collection in $obj2 (Group)
+ $obj2->addGroupResource($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Resource rows
+
+ $key3 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ResourcePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ResourcePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ResourcePeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (GroupResource) to the collection in $obj3 (Resource)
+ $obj3->addGroupResource($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Group table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptGroup(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupResourcePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Resource table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptResource(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ GroupResourcePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of GroupResource objects pre-filled with all related objects except Group.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupResource objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+ }
+
+ GroupResourcePeer::addSelectColumns($criteria);
+ $startcol2 = GroupResourcePeer::NUM_HYDRATE_COLUMNS;
+
+ ResourcePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ResourcePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = GroupResourcePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupResourcePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Resource rows
+
+ $key2 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ResourcePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ResourcePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ResourcePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (GroupResource) to the collection in $obj2 (Resource)
+ $obj2->addGroupResource($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of GroupResource objects pre-filled with all related objects except Resource.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of GroupResource objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+ }
+
+ GroupResourcePeer::addSelectColumns($criteria);
+ $startcol2 = GroupResourcePeer::NUM_HYDRATE_COLUMNS;
+
+ GroupPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = GroupResourcePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ GroupResourcePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Group rows
+
+ $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = GroupPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = GroupPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ GroupPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (GroupResource) to the collection in $obj2 (Group)
+ $obj2->addGroupResource($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -629,7 +1254,6 @@ abstract class BaseGroupResourcePeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += GroupResourcePeer::doOnDeleteCascade(new Criteria(GroupResourcePeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(GroupResourcePeer::TABLE_NAME, $con, GroupResourcePeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -663,14 +1287,24 @@ abstract class BaseGroupResourcePeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ GroupResourcePeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof GroupResource) { // it's a model object
+ // invalidate the cache for this single object
+ GroupResourcePeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(GroupResourcePeer::DATABASE_NAME);
$criteria->add(GroupResourcePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ GroupResourcePeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -683,23 +1317,6 @@ abstract class BaseGroupResourcePeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += GroupResourcePeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- GroupResourcePeer::clearInstancePool();
- } elseif ($values instanceof GroupResource) { // it's a model object
- GroupResourcePeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- GroupResourcePeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
GroupResourcePeer::clearRelatedInstancePool();
$con->commit();
@@ -711,45 +1328,6 @@ abstract class BaseGroupResourcePeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = GroupResourcePeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Group objects
- $criteria = new Criteria(GroupPeer::DATABASE_NAME);
-
- $criteria->add(GroupPeer::ID, $obj->getGroupId());
- $affectedRows += GroupPeer::doDelete($criteria, $con);
-
- // delete related Resource objects
- $criteria = new Criteria(ResourcePeer::DATABASE_NAME);
-
- $criteria->add(ResourcePeer::ID, $obj->getResourceId());
- $affectedRows += ResourcePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given GroupResource object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php
index 1feb537be..da6d5aa02 100644
--- a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php
+++ b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php
@@ -81,7 +81,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\GroupResource', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\GroupResource', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -284,6 +284,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria
* $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
*
*
+ * @see filterByGroup()
+ *
* @param mixed $groupId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -325,6 +327,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria
* $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12
*
*
+ * @see filterByResource()
+ *
* @param mixed $resourceId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -527,7 +531,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria
/**
* Filter the query by a related Group object
*
- * @param Group|PropelObjectCollection $group the related object to use as filter
+ * @param Group|PropelObjectCollection $group The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return GroupResourceQuery The current query, for fluid interface
@@ -539,10 +543,12 @@ abstract class BaseGroupResourceQuery extends ModelCriteria
return $this
->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->getId(), $comparison);
} elseif ($group instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useGroupQuery()
- ->filterByPrimaryKeys($group->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
}
@@ -601,7 +607,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria
/**
* Filter the query by a related Resource object
*
- * @param Resource|PropelObjectCollection $resource the related object to use as filter
+ * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return GroupResourceQuery The current query, for fluid interface
@@ -613,10 +619,12 @@ abstract class BaseGroupResourceQuery extends ModelCriteria
return $this
->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->getId(), $comparison);
} elseif ($resource instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useResourceQuery()
- ->filterByPrimaryKeys($resource->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseImage.php b/core/lib/Thelia/Model/om/BaseImage.php
index bffde9017..83f575469 100644
--- a/core/lib/Thelia/Model/om/BaseImage.php
+++ b/core/lib/Thelia/Model/om/BaseImage.php
@@ -112,29 +112,30 @@ abstract class BaseImage extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var ImageDesc
+ * @var Product
*/
- protected $aImageDesc;
+ protected $aProduct;
/**
- * @var Category one-to-one related Category object
+ * @var Category
*/
- protected $singleCategory;
+ protected $aCategory;
/**
- * @var Content one-to-one related Content object
+ * @var Content
*/
- protected $singleContent;
+ protected $aContent;
/**
- * @var Folder one-to-one related Folder object
+ * @var Folder
*/
- protected $singleFolder;
+ protected $aFolder;
/**
- * @var Product one-to-one related Product object
+ * @var PropelObjectCollection|ImageDesc[] Collection to store aggregation of ImageDesc objects.
*/
- protected $singleProduct;
+ protected $collImageDescs;
+ protected $collImageDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -154,25 +155,7 @@ abstract class BaseImage extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $categorysScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $contentsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $foldersScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
+ protected $imageDescsScheduledForDeletion = null;
/**
* Get the [id] column value.
@@ -335,10 +318,6 @@ abstract class BaseImage extends BaseObject implements Persistent
$this->modifiedColumns[] = ImagePeer::ID;
}
- if ($this->aImageDesc !== null && $this->aImageDesc->getImageId() !== $v) {
- $this->aImageDesc = null;
- }
-
return $this;
} // setId()
@@ -360,6 +339,10 @@ abstract class BaseImage extends BaseObject implements Persistent
$this->modifiedColumns[] = ImagePeer::PRODUCT_ID;
}
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
return $this;
} // setProductId()
@@ -381,6 +364,10 @@ abstract class BaseImage extends BaseObject implements Persistent
$this->modifiedColumns[] = ImagePeer::CATEGORY_ID;
}
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
return $this;
} // setCategoryId()
@@ -402,6 +389,10 @@ abstract class BaseImage extends BaseObject implements Persistent
$this->modifiedColumns[] = ImagePeer::FOLDER_ID;
}
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
return $this;
} // setFolderId()
@@ -423,6 +414,10 @@ abstract class BaseImage extends BaseObject implements Persistent
$this->modifiedColumns[] = ImagePeer::CONTENT_ID;
}
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
return $this;
} // setContentId()
@@ -587,8 +582,17 @@ abstract class BaseImage extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aImageDesc !== null && $this->id !== $this->aImageDesc->getImageId()) {
- $this->aImageDesc = null;
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
}
} // ensureConsistency
@@ -629,14 +633,11 @@ abstract class BaseImage extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aImageDesc = null;
- $this->singleCategory = null;
-
- $this->singleContent = null;
-
- $this->singleFolder = null;
-
- $this->singleProduct = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ $this->collImageDescs = null;
} // if (deep)
}
@@ -756,11 +757,32 @@ abstract class BaseImage extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aImageDesc !== null) {
- if ($this->aImageDesc->isModified() || $this->aImageDesc->isNew()) {
- $affectedRows += $this->aImageDesc->save($con);
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
}
- $this->setImageDesc($this->aImageDesc);
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
}
if ($this->isNew() || $this->isModified()) {
@@ -774,63 +796,21 @@ abstract class BaseImage extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->categorysScheduledForDeletion !== null) {
- if (!$this->categorysScheduledForDeletion->isEmpty()) {
- CategoryQuery::create()
- ->filterByPrimaryKeys($this->categorysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->categorysScheduledForDeletion = null;
+ if ($this->imageDescsScheduledForDeletion !== null) {
+ if (!$this->imageDescsScheduledForDeletion->isEmpty()) {
+ foreach ($this->imageDescsScheduledForDeletion as $imageDesc) {
+ // need to save related object because we set the relation to null
+ $imageDesc->save($con);
+ }
+ $this->imageDescsScheduledForDeletion = null;
}
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->isDeleted()) {
- $affectedRows += $this->singleCategory->save($con);
- }
- }
-
- if ($this->contentsScheduledForDeletion !== null) {
- if (!$this->contentsScheduledForDeletion->isEmpty()) {
- ContentQuery::create()
- ->filterByPrimaryKeys($this->contentsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->contentsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->isDeleted()) {
- $affectedRows += $this->singleContent->save($con);
- }
- }
-
- if ($this->foldersScheduledForDeletion !== null) {
- if (!$this->foldersScheduledForDeletion->isEmpty()) {
- FolderQuery::create()
- ->filterByPrimaryKeys($this->foldersScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->foldersScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->isDeleted()) {
- $affectedRows += $this->singleFolder->save($con);
- }
- }
-
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
+ if ($this->collImageDescs !== null) {
+ foreach ($this->collImageDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
}
}
@@ -1024,9 +1004,27 @@ abstract class BaseImage extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aImageDesc !== null) {
- if (!$this->aImageDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aImageDesc->getValidationFailures());
+ if ($this->aProduct !== null) {
+ if (!$this->aProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
+ }
+ }
+
+ if ($this->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+ if ($this->aContent !== null) {
+ if (!$this->aContent->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures());
+ }
+ }
+
+ if ($this->aFolder !== null) {
+ if (!$this->aFolder->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures());
}
}
@@ -1036,27 +1034,11 @@ abstract class BaseImage extends BaseObject implements Persistent
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCategory->getValidationFailures());
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleContent->getValidationFailures());
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFolder->getValidationFailures());
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
+ if ($this->collImageDescs !== null) {
+ foreach ($this->collImageDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
}
}
@@ -1162,20 +1144,20 @@ abstract class BaseImage extends BaseObject implements Persistent
$keys[8] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aImageDesc) {
- $result['ImageDesc'] = $this->aImageDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleCategory) {
- $result['Category'] = $this->singleCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleContent) {
- $result['Content'] = $this->singleContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleFolder) {
- $result['Folder'] = $this->singleFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collImageDescs) {
+ $result['ImageDescs'] = $this->collImageDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1370,29 +1352,10 @@ abstract class BaseImage extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCategory();
- if ($relObj) {
- $copyObj->setCategory($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getContent();
- if ($relObj) {
- $copyObj->setContent($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getFolder();
- if ($relObj) {
- $copyObj->setFolder($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getImageDesc();
- if ($relObj) {
- $copyObj->setImageDesc($relObj->copy($deepCopy));
+ foreach ($this->getImageDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImageDesc($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1446,25 +1409,26 @@ abstract class BaseImage extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a ImageDesc object.
+ * Declares an association between this object and a Product object.
*
- * @param ImageDesc $v
+ * @param Product $v
* @return Image The current object (for fluent API support)
* @throws PropelException
*/
- public function setImageDesc(ImageDesc $v = null)
+ public function setProduct(Product $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setProductId(NULL);
} else {
- $this->setId($v->getImageId());
+ $this->setProductId($v->getId());
}
- $this->aImageDesc = $v;
+ $this->aProduct = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // 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 ($v !== null) {
- $v->setImage($this);
+ $v->addImage($this);
}
@@ -1473,23 +1437,179 @@ abstract class BaseImage extends BaseObject implements Persistent
/**
- * Get the associated ImageDesc object
+ * Get the associated Product object
*
* @param PropelPDO $con Optional Connection object.
- * @return ImageDesc The associated ImageDesc object.
+ * @return Product The associated Product object.
* @throws PropelException
*/
- public function getImageDesc(PropelPDO $con = null)
+ public function getProduct(PropelPDO $con = null)
{
- if ($this->aImageDesc === null && ($this->id !== null)) {
- $this->aImageDesc = ImageDescQuery::create()
- ->filterByImage($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aImageDesc->setImage($this);
+ 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->aProduct->addImages($this);
+ */
}
- return $this->aImageDesc;
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return Image The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(Category $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Category object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImage($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Category object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Category The associated Category object.
+ * @throws PropelException
+ */
+ public function getCategory(PropelPDO $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->category_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->aCategory->addImages($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a Content object.
+ *
+ * @param Content $v
+ * @return Image The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(Content $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Content object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImage($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Content object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Content The associated Content object.
+ * @throws PropelException
+ */
+ public function getContent(PropelPDO $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ContentQuery::create()->findPk($this->content_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->aContent->addImages($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Declares an association between this object and a Folder object.
+ *
+ * @param Folder $v
+ * @return Image The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(Folder $v = null)
+ {
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Folder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImage($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Folder object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Folder The associated Folder object.
+ * @throws PropelException
+ */
+ public function getFolder(PropelPDO $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = FolderQuery::create()->findPk($this->folder_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->aFolder->addImages($this);
+ */
+ }
+
+ return $this->aFolder;
}
@@ -1503,150 +1623,216 @@ abstract class BaseImage extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ if ('ImageDesc' == $relationName) {
+ $this->initImageDescs();
+ }
}
/**
- * Gets a single Category object, which is related to this object by a one-to-one relationship.
+ * Clears out the collImageDescs 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 addImageDescs()
+ */
+ public function clearImageDescs()
+ {
+ $this->collImageDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collImageDescsPartial = null;
+ }
+
+ /**
+ * reset is the collImageDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialImageDescs($v = true)
+ {
+ $this->collImageDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collImageDescs collection.
+ *
+ * By default this just sets the collImageDescs collection to an empty array (like clearcollImageDescs());
+ * 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 initImageDescs($overrideExisting = true)
+ {
+ if (null !== $this->collImageDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collImageDescs = new PropelObjectCollection();
+ $this->collImageDescs->setModel('ImageDesc');
+ }
+
+ /**
+ * Gets an array of ImageDesc 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 Image 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 Category
+ * @return PropelObjectCollection|ImageDesc[] List of ImageDesc objects
* @throws PropelException
*/
- public function getCategory(PropelPDO $con = null)
+ public function getImageDescs($criteria = null, PropelPDO $con = null)
{
+ $partial = $this->collImageDescsPartial && !$this->isNew();
+ if (null === $this->collImageDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImageDescs) {
+ // return empty collection
+ $this->initImageDescs();
+ } else {
+ $collImageDescs = ImageDescQuery::create(null, $criteria)
+ ->filterByImage($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collImageDescsPartial && count($collImageDescs)) {
+ $this->initImageDescs(false);
- if ($this->singleCategory === null && !$this->isNew()) {
- $this->singleCategory = CategoryQuery::create()->findPk($this->getPrimaryKey(), $con);
+ foreach($collImageDescs as $obj) {
+ if (false == $this->collImageDescs->contains($obj)) {
+ $this->collImageDescs->append($obj);
+ }
+ }
+
+ $this->collImageDescsPartial = true;
+ }
+
+ return $collImageDescs;
+ }
+
+ if($partial && $this->collImageDescs) {
+ foreach($this->collImageDescs as $obj) {
+ if($obj->isNew()) {
+ $collImageDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collImageDescs = $collImageDescs;
+ $this->collImageDescsPartial = false;
+ }
}
- return $this->singleCategory;
+ return $this->collImageDescs;
}
/**
- * Sets a single Category object as related to this object by a one-to-one relationship.
+ * Sets a collection of ImageDesc 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 Category $v Category
- * @return Image The current object (for fluent API support)
+ * @param PropelCollection $imageDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setImageDescs(PropelCollection $imageDescs, PropelPDO $con = null)
+ {
+ $this->imageDescsScheduledForDeletion = $this->getImageDescs(new Criteria(), $con)->diff($imageDescs);
+
+ foreach ($this->imageDescsScheduledForDeletion as $imageDescRemoved) {
+ $imageDescRemoved->setImage(null);
+ }
+
+ $this->collImageDescs = null;
+ foreach ($imageDescs as $imageDesc) {
+ $this->addImageDesc($imageDesc);
+ }
+
+ $this->collImageDescs = $imageDescs;
+ $this->collImageDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related ImageDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ImageDesc objects.
* @throws PropelException
*/
- public function setCategory(Category $v = null)
+ public function countImageDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleCategory = $v;
+ $partial = $this->collImageDescsPartial && !$this->isNew();
+ if (null === $this->collImageDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImageDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getImageDescs());
+ }
+ $query = ImageDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
- // Make sure that that the passed-in Category isn't already associated with this object
- if ($v !== null && $v->getImage() === null) {
- $v->setImage($this);
+ return $query
+ ->filterByImage($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collImageDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a ImageDesc object to this object
+ * through the ImageDesc foreign key attribute.
+ *
+ * @param ImageDesc $l ImageDesc
+ * @return Image The current object (for fluent API support)
+ */
+ public function addImageDesc(ImageDesc $l)
+ {
+ if ($this->collImageDescs === null) {
+ $this->initImageDescs();
+ $this->collImageDescsPartial = true;
+ }
+ if (!$this->collImageDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddImageDesc($l);
}
return $this;
}
/**
- * Gets a single Content object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Content
- * @throws PropelException
+ * @param ImageDesc $imageDesc The imageDesc object to add.
*/
- public function getContent(PropelPDO $con = null)
+ protected function doAddImageDesc($imageDesc)
{
-
- if ($this->singleContent === null && !$this->isNew()) {
- $this->singleContent = ContentQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleContent;
+ $this->collImageDescs[]= $imageDesc;
+ $imageDesc->setImage($this);
}
/**
- * Sets a single Content object as related to this object by a one-to-one relationship.
- *
- * @param Content $v Content
- * @return Image The current object (for fluent API support)
- * @throws PropelException
+ * @param ImageDesc $imageDesc The imageDesc object to remove.
*/
- public function setContent(Content $v = null)
+ public function removeImageDesc($imageDesc)
{
- $this->singleContent = $v;
-
- // Make sure that that the passed-in Content isn't already associated with this object
- if ($v !== null && $v->getImage() === null) {
- $v->setImage($this);
+ if ($this->getImageDescs()->contains($imageDesc)) {
+ $this->collImageDescs->remove($this->collImageDescs->search($imageDesc));
+ if (null === $this->imageDescsScheduledForDeletion) {
+ $this->imageDescsScheduledForDeletion = clone $this->collImageDescs;
+ $this->imageDescsScheduledForDeletion->clear();
+ }
+ $this->imageDescsScheduledForDeletion[]= $imageDesc;
+ $imageDesc->setImage(null);
}
-
- return $this;
- }
-
- /**
- * Gets a single Folder object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Folder
- * @throws PropelException
- */
- public function getFolder(PropelPDO $con = null)
- {
-
- if ($this->singleFolder === null && !$this->isNew()) {
- $this->singleFolder = FolderQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleFolder;
- }
-
- /**
- * Sets a single Folder object as related to this object by a one-to-one relationship.
- *
- * @param Folder $v Folder
- * @return Image The current object (for fluent API support)
- * @throws PropelException
- */
- public function setFolder(Folder $v = null)
- {
- $this->singleFolder = $v;
-
- // Make sure that that the passed-in Folder isn't already associated with this object
- if ($v !== null && $v->getImage() === null) {
- $v->setImage($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Product
- * @throws PropelException
- */
- public function getProduct(PropelPDO $con = null)
- {
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleProduct;
- }
-
- /**
- * Sets a single Product object as related to this object by a one-to-one relationship.
- *
- * @param Product $v Product
- * @return Image The current object (for fluent API support)
- * @throws PropelException
- */
- public function setProduct(Product $v = null)
- {
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getImage() === null) {
- $v->setImage($this);
- }
-
- return $this;
}
/**
@@ -1683,37 +1869,21 @@ abstract class BaseImage extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCategory) {
- $this->singleCategory->clearAllReferences($deep);
- }
- if ($this->singleContent) {
- $this->singleContent->clearAllReferences($deep);
- }
- if ($this->singleFolder) {
- $this->singleFolder->clearAllReferences($deep);
- }
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
+ if ($this->collImageDescs) {
+ foreach ($this->collImageDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
}
} // if ($deep)
- if ($this->singleCategory instanceof PropelCollection) {
- $this->singleCategory->clearIterator();
+ if ($this->collImageDescs instanceof PropelCollection) {
+ $this->collImageDescs->clearIterator();
}
- $this->singleCategory = null;
- if ($this->singleContent instanceof PropelCollection) {
- $this->singleContent->clearIterator();
- }
- $this->singleContent = null;
- if ($this->singleFolder instanceof PropelCollection) {
- $this->singleFolder->clearIterator();
- }
- $this->singleFolder = null;
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
- $this->aImageDesc = null;
+ $this->collImageDescs = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseImageDesc.php b/core/lib/Thelia/Model/om/BaseImageDesc.php
index 0297a17b4..baf8e28b9 100644
--- a/core/lib/Thelia/Model/om/BaseImageDesc.php
+++ b/core/lib/Thelia/Model/om/BaseImageDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Image;
use Thelia\Model\ImageDesc;
@@ -92,9 +90,9 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Image one-to-one related Image object
+ * @var Image
*/
- protected $singleImage;
+ protected $aImage;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -110,12 +108,6 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $imagesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -278,6 +270,10 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = ImageDescPeer::IMAGE_ID;
}
+ if ($this->aImage !== null && $this->aImage->getId() !== $v) {
+ $this->aImage = null;
+ }
+
return $this;
} // setImageId()
@@ -461,6 +457,9 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aImage !== null && $this->image_id !== $this->aImage->getId()) {
+ $this->aImage = null;
+ }
} // ensureConsistency
/**
@@ -500,8 +499,7 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleImage = null;
-
+ $this->aImage = null;
} // if (deep)
}
@@ -615,6 +613,18 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aImage !== null) {
+ if ($this->aImage->isModified() || $this->aImage->isNew()) {
+ $affectedRows += $this->aImage->save($con);
+ }
+ $this->setImage($this->aImage);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -626,21 +636,6 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->imagesScheduledForDeletion !== null) {
- if (!$this->imagesScheduledForDeletion->isEmpty()) {
- ImageQuery::create()
- ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->imagesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleImage !== null) {
- if (!$this->singleImage->isDeleted()) {
- $affectedRows += $this->singleImage->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -814,17 +809,23 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aImage !== null) {
+ if (!$this->aImage->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aImage->getValidationFailures());
+ }
+ }
+
+
if (($retval = ImageDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleImage !== null) {
- if (!$this->singleImage->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleImage->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -919,8 +920,8 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleImage) {
- $result['Image'] = $this->singleImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aImage) {
+ $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1103,11 +1104,6 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getImage();
- if ($relObj) {
- $copyObj->setImage($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1158,55 +1154,57 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Image object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Image object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Image
- * @throws PropelException
- */
- public function getImage(PropelPDO $con = null)
- {
-
- if ($this->singleImage === null && !$this->isNew()) {
- $this->singleImage = ImageQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleImage;
- }
-
- /**
- * Sets a single Image object as related to this object by a one-to-one relationship.
- *
- * @param Image $v Image
+ * @param Image $v
* @return ImageDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setImage(Image $v = null)
{
- $this->singleImage = $v;
-
- // Make sure that that the passed-in Image isn't already associated with this object
- if ($v !== null && $v->getImageDesc() === null) {
- $v->setImageDesc($this);
+ if ($v === null) {
+ $this->setImageId(NULL);
+ } else {
+ $this->setImageId($v->getId());
}
+ $this->aImage = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Image object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImageDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Image object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Image The associated Image object.
+ * @throws PropelException
+ */
+ public function getImage(PropelPDO $con = null)
+ {
+ if ($this->aImage === null && ($this->image_id !== null)) {
+ $this->aImage = ImageQuery::create()->findPk($this->image_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->aImage->addImageDescs($this);
+ */
+ }
+
+ return $this->aImage;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1239,15 +1237,9 @@ abstract class BaseImageDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleImage) {
- $this->singleImage->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleImage instanceof PropelCollection) {
- $this->singleImage->clearIterator();
- }
- $this->singleImage = null;
+ $this->aImage = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseImageDescPeer.php b/core/lib/Thelia/Model/om/BaseImageDescPeer.php
index b0d99c47c..6025a9ebc 100644
--- a/core/lib/Thelia/Model/om/BaseImageDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseImageDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseImageDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'image_desc';
@@ -393,9 +393,6 @@ abstract class BaseImageDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in ImagePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ImagePeer::clearInstancePool();
}
/**
@@ -492,6 +489,244 @@ abstract class BaseImageDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Image table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinImage(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImageDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImageDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImageDescPeer::IMAGE_ID, ImagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ImageDesc objects pre-filled with their Image objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ImageDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME);
+ }
+
+ ImageDescPeer::addSelectColumns($criteria);
+ $startcol = ImageDescPeer::NUM_HYDRATE_COLUMNS;
+ ImagePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ImageDescPeer::IMAGE_ID, ImagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImageDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImageDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ImageDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImageDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ImagePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ImagePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ImagePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ImageDesc) to $obj2 (Image)
+ $obj2->addImageDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImageDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImageDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImageDescPeer::IMAGE_ID, ImagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ImageDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ImageDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME);
+ }
+
+ ImageDescPeer::addSelectColumns($criteria);
+ $startcol2 = ImageDescPeer::NUM_HYDRATE_COLUMNS;
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ImagePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ImageDescPeer::IMAGE_ID, ImagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImageDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImageDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ImageDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImageDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Image rows
+
+ $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ImagePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ImagePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ImagePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ImageDesc) to the collection in $obj2 (Image)
+ $obj2->addImageDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -625,7 +860,6 @@ abstract class BaseImageDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ImageDescPeer::doOnDeleteCascade(new Criteria(ImageDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ImageDescPeer::TABLE_NAME, $con, ImageDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -659,14 +893,24 @@ abstract class BaseImageDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ImageDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ImageDesc) { // it's a model object
+ // invalidate the cache for this single object
+ ImageDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ImageDescPeer::DATABASE_NAME);
$criteria->add(ImageDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ImageDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -679,23 +923,6 @@ abstract class BaseImageDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ImageDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ImageDescPeer::clearInstancePool();
- } elseif ($values instanceof ImageDesc) { // it's a model object
- ImageDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ImageDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ImageDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -707,39 +934,6 @@ abstract class BaseImageDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ImageDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Image objects
- $criteria = new Criteria(ImagePeer::DATABASE_NAME);
-
- $criteria->add(ImagePeer::ID, $obj->getImageId());
- $affectedRows += ImagePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ImageDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseImageDescQuery.php b/core/lib/Thelia/Model/om/BaseImageDescQuery.php
index 00512bcca..e4aba6205 100644
--- a/core/lib/Thelia/Model/om/BaseImageDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseImageDescQuery.php
@@ -76,7 +76,7 @@ abstract class BaseImageDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ImageDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ImageDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -279,6 +279,8 @@ abstract class BaseImageDescQuery extends ModelCriteria
* $query->filterByImageId(array('min' => 12)); // WHERE image_id > 12
*
*
+ * @see filterByImage()
+ *
* @param mixed $imageId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -486,7 +488,7 @@ abstract class BaseImageDescQuery extends ModelCriteria
/**
* Filter the query by a related Image object
*
- * @param Image|PropelObjectCollection $image the related object to use as filter
+ * @param Image|PropelObjectCollection $image The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ImageDescQuery The current query, for fluid interface
@@ -498,10 +500,12 @@ abstract class BaseImageDescQuery extends ModelCriteria
return $this
->addUsingAlias(ImageDescPeer::IMAGE_ID, $image->getId(), $comparison);
} elseif ($image instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useImageQuery()
- ->filterByPrimaryKeys($image->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ImageDescPeer::IMAGE_ID, $image->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
}
@@ -515,7 +519,7 @@ abstract class BaseImageDescQuery extends ModelCriteria
*
* @return ImageDescQuery The current query, for fluid interface
*/
- public function joinImage($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Image');
@@ -550,7 +554,7 @@ abstract class BaseImageDescQuery extends ModelCriteria
*
* @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
*/
- public function useImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinImage($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseImagePeer.php b/core/lib/Thelia/Model/om/BaseImagePeer.php
index f3345bb59..d529374bd 100644
--- a/core/lib/Thelia/Model/om/BaseImagePeer.php
+++ b/core/lib/Thelia/Model/om/BaseImagePeer.php
@@ -29,7 +29,7 @@ abstract class BaseImagePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'image';
@@ -407,18 +407,9 @@ abstract class BaseImagePeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CategoryPeer instance pool,
+ // Invalidate objects in ImageDescPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CategoryPeer::clearInstancePool();
- // Invalidate objects in ContentPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ContentPeer::clearInstancePool();
- // Invalidate objects in FolderPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FolderPeer::clearInstancePool();
- // Invalidate objects in ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
+ ImageDescPeer::clearInstancePool();
}
/**
@@ -517,7 +508,7 @@ abstract class BaseImagePeer
/**
- * Returns the number of rows matching criteria, joining the related ImageDesc 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.
@@ -525,7 +516,7 @@ abstract class BaseImagePeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinImageDesc(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;
@@ -552,7 +543,7 @@ abstract class BaseImagePeer
$con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(ImagePeer::ID, ImageDescPeer::IMAGE_ID, $join_behavior);
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -568,7 +559,160 @@ abstract class BaseImagePeer
/**
- * Selects a collection of Image objects pre-filled with their ImageDesc objects.
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImagePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImagePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImagePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Image 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
@@ -576,7 +720,7 @@ abstract class BaseImagePeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinImageDesc(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;
@@ -587,9 +731,9 @@ abstract class BaseImagePeer
ImagePeer::addSelectColumns($criteria);
$startcol = ImagePeer::NUM_HYDRATE_COLUMNS;
- ImageDescPeer::addSelectColumns($criteria);
+ ProductPeer::addSelectColumns($criteria);
- $criteria->addJoin(ImagePeer::ID, ImageDescPeer::IMAGE_ID, $join_behavior);
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -609,21 +753,221 @@ abstract class BaseImagePeer
ImagePeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = ImageDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = ImageDescPeer::getInstanceFromPool($key2);
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = ImageDescPeer::getOMClass();
+ $cls = ProductPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- ImageDescPeer::addInstanceToPool($obj2, $key2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (Image) to $obj2 (ImageDesc)
- // one to one relationship
- $obj1->setImageDesc($obj2);
+ // Add the $obj1 (Image) to $obj2 (Product)
+ $obj2->addImage($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Image objects pre-filled with their Category objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Image objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+ }
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol = ImagePeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ImagePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImagePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Image) to $obj2 (Category)
+ $obj2->addImage($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Image objects pre-filled with their Content objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Image objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+ }
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol = ImagePeer::NUM_HYDRATE_COLUMNS;
+ ContentPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ImagePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImagePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Image) to $obj2 (Content)
+ $obj2->addImage($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Image objects pre-filled with their Folder objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Image objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+ }
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol = ImagePeer::NUM_HYDRATE_COLUMNS;
+ FolderPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ImagePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImagePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FolderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FolderPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Image) to $obj2 (Folder)
+ $obj2->addImage($obj1);
} // if joined row was not null
@@ -671,7 +1015,13 @@ abstract class BaseImagePeer
$con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(ImagePeer::ID, ImageDescPeer::IMAGE_ID, $join_behavior);
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -707,10 +1057,25 @@ abstract class BaseImagePeer
ImagePeer::addSelectColumns($criteria);
$startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS;
- ImageDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ImageDescPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
- $criteria->addJoin(ImagePeer::ID, ImageDescPeer::IMAGE_ID, $join_behavior);
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol6 = $startcol5 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -729,24 +1094,786 @@ abstract class BaseImagePeer
ImagePeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined ImageDesc rows
+ // Add objects for joined Product rows
- $key2 = ImageDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = ImageDescPeer::getInstanceFromPool($key2);
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = ImageDescPeer::getOMClass();
+ $cls = ProductPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- ImageDescPeer::addInstanceToPool($obj2, $key2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (Image) to the collection in $obj2 (ImageDesc)
- $obj1->setImageDesc($obj2);
+ // Add the $obj1 (Image) to the collection in $obj2 (Product)
+ $obj2->addImage($obj1);
} // if joined row not null
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (Image) to the collection in $obj3 (Category)
+ $obj3->addImage($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Content rows
+
+ $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ContentPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ContentPeer::addInstanceToPool($obj4, $key4);
+ } // if obj4 loaded
+
+ // Add the $obj1 (Image) to the collection in $obj4 (Content)
+ $obj4->addImage($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Folder rows
+
+ $key5 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol5);
+ if ($key5 !== null) {
+ $obj5 = FolderPeer::getInstanceFromPool($key5);
+ if (!$obj5) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj5 = new $cls();
+ $obj5->hydrate($row, $startcol5);
+ FolderPeer::addInstanceToPool($obj5, $key5);
+ } // if obj5 loaded
+
+ // Add the $obj1 (Image) to the collection in $obj5 (Folder)
+ $obj5->addImage($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImagePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImagePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImagePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ImagePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Image objects pre-filled with all related objects except Product.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Image objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+ }
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ImagePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImagePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj2 (Category)
+ $obj2->addImage($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ContentPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ContentPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj3 (Content)
+ $obj3->addImage($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = FolderPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ FolderPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj4 (Folder)
+ $obj4->addImage($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Image objects pre-filled with all related objects except Category.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Image objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+ }
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ImagePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImagePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj2 (Product)
+ $obj2->addImage($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ContentPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ContentPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj3 (Content)
+ $obj3->addImage($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = FolderPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ FolderPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj4 (Folder)
+ $obj4->addImage($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Image objects pre-filled with all related objects except Content.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Image objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+ }
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ImagePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImagePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj2 (Product)
+ $obj2->addImage($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj3 (Category)
+ $obj3->addImage($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = FolderPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ FolderPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj4 (Folder)
+ $obj4->addImage($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Image objects pre-filled with all related objects except Folder.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Image objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+ }
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ImagePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ImagePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj2 (Product)
+ $obj2->addImage($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj3 (Category)
+ $obj3->addImage($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ContentPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ContentPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Image) to the collection in $obj4 (Content)
+ $obj4->addImage($obj1);
+
+ } // if joined row is not null
+
$results[] = $obj1;
}
$stmt->closeCursor();
@@ -887,7 +2014,6 @@ abstract class BaseImagePeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ImagePeer::doOnDeleteCascade(new Criteria(ImagePeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ImagePeer::TABLE_NAME, $con, ImagePeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -921,14 +2047,24 @@ abstract class BaseImagePeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ImagePeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Image) { // it's a model object
+ // invalidate the cache for this single object
+ ImagePeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ImagePeer::DATABASE_NAME);
$criteria->add(ImagePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ImagePeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -941,23 +2077,6 @@ abstract class BaseImagePeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ImagePeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ImagePeer::clearInstancePool();
- } elseif ($values instanceof Image) { // it's a model object
- ImagePeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ImagePeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ImagePeer::clearRelatedInstancePool();
$con->commit();
@@ -969,57 +2088,6 @@ abstract class BaseImagePeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ImagePeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Category objects
- $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
-
- $criteria->add(CategoryPeer::ID, $obj->getCategoryId());
- $affectedRows += CategoryPeer::doDelete($criteria, $con);
-
- // delete related Content objects
- $criteria = new Criteria(ContentPeer::DATABASE_NAME);
-
- $criteria->add(ContentPeer::ID, $obj->getContentId());
- $affectedRows += ContentPeer::doDelete($criteria, $con);
-
- // delete related Folder objects
- $criteria = new Criteria(FolderPeer::DATABASE_NAME);
-
- $criteria->add(FolderPeer::ID, $obj->getFolderId());
- $affectedRows += FolderPeer::doDelete($criteria, $con);
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given Image object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseImageQuery.php b/core/lib/Thelia/Model/om/BaseImageQuery.php
index 4f9ae335b..e4e390da2 100644
--- a/core/lib/Thelia/Model/om/BaseImageQuery.php
+++ b/core/lib/Thelia/Model/om/BaseImageQuery.php
@@ -50,9 +50,9 @@ use Thelia\Model\Product;
* @method ImageQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ImageQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method ImageQuery leftJoinImageDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ImageDesc relation
- * @method ImageQuery rightJoinImageDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ImageDesc relation
- * @method ImageQuery innerJoinImageDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the ImageDesc relation
+ * @method ImageQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
+ * @method ImageQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
+ * @method ImageQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
*
* @method ImageQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
* @method ImageQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
@@ -66,9 +66,9 @@ use Thelia\Model\Product;
* @method ImageQuery rightJoinFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Folder relation
* @method ImageQuery innerJoinFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the Folder relation
*
- * @method ImageQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
- * @method ImageQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
- * @method ImageQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
+ * @method ImageQuery leftJoinImageDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ImageDesc relation
+ * @method ImageQuery rightJoinImageDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ImageDesc relation
+ * @method ImageQuery innerJoinImageDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the ImageDesc relation
*
* @method Image findOne(PropelPDO $con = null) Return the first Image matching the query
* @method Image findOneOrCreate(PropelPDO $con = null) Return the first Image matching the query, or a new Image object populated from the query conditions when no match is found
@@ -104,7 +104,7 @@ abstract class BaseImageQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Image', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Image', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -280,8 +280,6 @@ abstract class BaseImageQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByImageDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -309,6 +307,8 @@ abstract class BaseImageQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProduct()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -350,6 +350,8 @@ abstract class BaseImageQuery extends ModelCriteria
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
*
*
+ * @see filterByCategory()
+ *
* @param mixed $categoryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -391,6 +393,8 @@ abstract class BaseImageQuery extends ModelCriteria
* $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
*
*
+ * @see filterByFolder()
+ *
* @param mixed $folderId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -432,6 +436,8 @@ abstract class BaseImageQuery extends ModelCriteria
* $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
*
*
+ * @see filterByContent()
+ *
* @param mixed $contentId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -619,308 +625,10 @@ abstract class BaseImageQuery extends ModelCriteria
return $this->addUsingAlias(ImagePeer::UPDATED_AT, $updatedAt, $comparison);
}
- /**
- * Filter the query by a related ImageDesc object
- *
- * @param ImageDesc|PropelObjectCollection $imageDesc The related object(s) to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ImageQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByImageDesc($imageDesc, $comparison = null)
- {
- if ($imageDesc instanceof ImageDesc) {
- return $this
- ->addUsingAlias(ImagePeer::ID, $imageDesc->getImageId(), $comparison);
- } elseif ($imageDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
- return $this
- ->addUsingAlias(ImagePeer::ID, $imageDesc->toKeyValue('PrimaryKey', 'ImageId'), $comparison);
- } else {
- throw new PropelException('filterByImageDesc() only accepts arguments of type ImageDesc or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the ImageDesc relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return ImageQuery The current query, for fluid interface
- */
- public function joinImageDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('ImageDesc');
-
- // 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, 'ImageDesc');
- }
-
- return $this;
- }
-
- /**
- * Use the ImageDesc relation ImageDesc 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\ImageDescQuery A secondary query class using the current class as primary query
- */
- public function useImageDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinImageDesc($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'ImageDesc', '\Thelia\Model\ImageDescQuery');
- }
-
- /**
- * Filter the query by a related Category object
- *
- * @param Category|PropelObjectCollection $category the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ImageQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByCategory($category, $comparison = null)
- {
- if ($category instanceof Category) {
- return $this
- ->addUsingAlias(ImagePeer::CATEGORY_ID, $category->getId(), $comparison);
- } elseif ($category instanceof PropelObjectCollection) {
- return $this
- ->useCategoryQuery()
- ->filterByPrimaryKeys($category->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Category relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return ImageQuery The current query, for fluid interface
- */
- public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Category');
-
- // 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, 'Category');
- }
-
- return $this;
- }
-
- /**
- * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query
- */
- public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinCategory($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
- }
-
- /**
- * Filter the query by a related Content object
- *
- * @param Content|PropelObjectCollection $content the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ImageQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByContent($content, $comparison = null)
- {
- if ($content instanceof Content) {
- return $this
- ->addUsingAlias(ImagePeer::CONTENT_ID, $content->getId(), $comparison);
- } elseif ($content instanceof PropelObjectCollection) {
- return $this
- ->useContentQuery()
- ->filterByPrimaryKeys($content->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Content relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return ImageQuery The current query, for fluid interface
- */
- public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Content');
-
- // 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, 'Content');
- }
-
- return $this;
- }
-
- /**
- * Use the Content relation Content 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\ContentQuery A secondary query class using the current class as primary query
- */
- public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinContent($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
- }
-
- /**
- * Filter the query by a related Folder object
- *
- * @param Folder|PropelObjectCollection $folder the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ImageQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByFolder($folder, $comparison = null)
- {
- if ($folder instanceof Folder) {
- return $this
- ->addUsingAlias(ImagePeer::FOLDER_ID, $folder->getId(), $comparison);
- } elseif ($folder instanceof PropelObjectCollection) {
- return $this
- ->useFolderQuery()
- ->filterByPrimaryKeys($folder->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Folder relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return ImageQuery The current query, for fluid interface
- */
- public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Folder');
-
- // 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, 'Folder');
- }
-
- return $this;
- }
-
- /**
- * Use the Folder relation Folder 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\FolderQuery A secondary query class using the current class as primary query
- */
- public function useFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinFolder($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
- }
-
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product the related object 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 ImageQuery The current query, for fluid interface
@@ -932,10 +640,12 @@ abstract class BaseImageQuery extends ModelCriteria
return $this
->addUsingAlias(ImagePeer::PRODUCT_ID, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ImagePeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
}
@@ -949,7 +659,7 @@ abstract class BaseImageQuery extends ModelCriteria
*
* @return ImageQuery The current query, for fluid interface
*/
- public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Product');
@@ -984,13 +694,315 @@ abstract class BaseImageQuery extends ModelCriteria
*
* @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
*/
- public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinProduct($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
}
+ /**
+ * Filter the query by a related Category object
+ *
+ * @param Category|PropelObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof Category) {
+ return $this
+ ->addUsingAlias(ImagePeer::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImagePeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // 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, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related Content object
+ *
+ * @param Content|PropelObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof Content) {
+ return $this
+ ->addUsingAlias(ImagePeer::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImagePeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // 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, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content 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\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Filter the query by a related Folder object
+ *
+ * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof Folder) {
+ return $this
+ ->addUsingAlias(ImagePeer::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImagePeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // 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, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder 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\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
+ /**
+ * Filter the query by a related ImageDesc object
+ *
+ * @param ImageDesc|PropelObjectCollection $imageDesc the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByImageDesc($imageDesc, $comparison = null)
+ {
+ if ($imageDesc instanceof ImageDesc) {
+ return $this
+ ->addUsingAlias(ImagePeer::ID, $imageDesc->getImageId(), $comparison);
+ } elseif ($imageDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useImageDescQuery()
+ ->filterByPrimaryKeys($imageDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImageDesc() only accepts arguments of type ImageDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ImageDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function joinImageDesc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ImageDesc');
+
+ // 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, 'ImageDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ImageDesc relation ImageDesc 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\ImageDescQuery A secondary query class using the current class as primary query
+ */
+ public function useImageDescQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImageDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ImageDesc', '\Thelia\Model\ImageDescQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseLangPeer.php b/core/lib/Thelia/Model/om/BaseLangPeer.php
index 62250857e..4282c0a19 100644
--- a/core/lib/Thelia/Model/om/BaseLangPeer.php
+++ b/core/lib/Thelia/Model/om/BaseLangPeer.php
@@ -24,7 +24,7 @@ abstract class BaseLangPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'lang';
diff --git a/core/lib/Thelia/Model/om/BaseLangQuery.php b/core/lib/Thelia/Model/om/BaseLangQuery.php
index 001015420..0e084a87d 100644
--- a/core/lib/Thelia/Model/om/BaseLangQuery.php
+++ b/core/lib/Thelia/Model/om/BaseLangQuery.php
@@ -69,7 +69,7 @@ abstract class BaseLangQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Lang', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Lang', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
diff --git a/core/lib/Thelia/Model/om/BaseMessage.php b/core/lib/Thelia/Model/om/BaseMessage.php
index 6c0927ab2..6f3fb5622 100644
--- a/core/lib/Thelia/Model/om/BaseMessage.php
+++ b/core/lib/Thelia/Model/om/BaseMessage.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Message;
use Thelia\Model\MessageDesc;
@@ -78,9 +80,10 @@ abstract class BaseMessage extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var MessageDesc
+ * @var PropelObjectCollection|MessageDesc[] Collection to store aggregation of MessageDesc objects.
*/
- protected $aMessageDesc;
+ protected $collMessageDescs;
+ protected $collMessageDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -96,6 +99,12 @@ abstract class BaseMessage extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $messageDescsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -217,10 +226,6 @@ abstract class BaseMessage extends BaseObject implements Persistent
$this->modifiedColumns[] = MessagePeer::ID;
}
- if ($this->aMessageDesc !== null && $this->aMessageDesc->getMessageId() !== $v) {
- $this->aMessageDesc = null;
- }
-
return $this;
} // setId()
@@ -381,9 +386,6 @@ abstract class BaseMessage extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aMessageDesc !== null && $this->id !== $this->aMessageDesc->getMessageId()) {
- $this->aMessageDesc = null;
- }
} // ensureConsistency
/**
@@ -423,7 +425,8 @@ abstract class BaseMessage extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aMessageDesc = null;
+ $this->collMessageDescs = null;
+
} // if (deep)
}
@@ -537,18 +540,6 @@ abstract class BaseMessage extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aMessageDesc !== null) {
- if ($this->aMessageDesc->isModified() || $this->aMessageDesc->isNew()) {
- $affectedRows += $this->aMessageDesc->save($con);
- }
- $this->setMessageDesc($this->aMessageDesc);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -560,6 +551,23 @@ abstract class BaseMessage extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->messageDescsScheduledForDeletion !== null) {
+ if (!$this->messageDescsScheduledForDeletion->isEmpty()) {
+ MessageDescQuery::create()
+ ->filterByPrimaryKeys($this->messageDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->messageDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collMessageDescs !== null) {
+ foreach ($this->collMessageDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -721,23 +729,19 @@ abstract class BaseMessage extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aMessageDesc !== null) {
- if (!$this->aMessageDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aMessageDesc->getValidationFailures());
- }
- }
-
-
if (($retval = MessagePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collMessageDescs !== null) {
+ foreach ($this->collMessageDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -824,8 +828,8 @@ abstract class BaseMessage extends BaseObject implements Persistent
$keys[4] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aMessageDesc) {
- $result['MessageDesc'] = $this->aMessageDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collMessageDescs) {
+ $result['MessageDescs'] = $this->collMessageDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -996,9 +1000,10 @@ abstract class BaseMessage extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getMessageDesc();
- if ($relObj) {
- $copyObj->setMessageDesc($relObj->copy($deepCopy));
+ foreach ($this->getMessageDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addMessageDesc($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1051,51 +1056,227 @@ abstract class BaseMessage extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a MessageDesc object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param MessageDesc $v
- * @return Message The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('MessageDesc' == $relationName) {
+ $this->initMessageDescs();
+ }
+ }
+
+ /**
+ * Clears out the collMessageDescs 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 addMessageDescs()
+ */
+ public function clearMessageDescs()
+ {
+ $this->collMessageDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collMessageDescsPartial = null;
+ }
+
+ /**
+ * reset is the collMessageDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialMessageDescs($v = true)
+ {
+ $this->collMessageDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collMessageDescs collection.
+ *
+ * By default this just sets the collMessageDescs collection to an empty array (like clearcollMessageDescs());
+ * 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 initMessageDescs($overrideExisting = true)
+ {
+ if (null !== $this->collMessageDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collMessageDescs = new PropelObjectCollection();
+ $this->collMessageDescs->setModel('MessageDesc');
+ }
+
+ /**
+ * Gets an array of MessageDesc 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 Message 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|MessageDesc[] List of MessageDesc objects
* @throws PropelException
*/
- public function setMessageDesc(MessageDesc $v = null)
+ public function getMessageDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collMessageDescsPartial && !$this->isNew();
+ if (null === $this->collMessageDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collMessageDescs) {
+ // return empty collection
+ $this->initMessageDescs();
+ } else {
+ $collMessageDescs = MessageDescQuery::create(null, $criteria)
+ ->filterByMessage($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collMessageDescsPartial && count($collMessageDescs)) {
+ $this->initMessageDescs(false);
+
+ foreach($collMessageDescs as $obj) {
+ if (false == $this->collMessageDescs->contains($obj)) {
+ $this->collMessageDescs->append($obj);
+ }
+ }
+
+ $this->collMessageDescsPartial = true;
+ }
+
+ return $collMessageDescs;
+ }
+
+ if($partial && $this->collMessageDescs) {
+ foreach($this->collMessageDescs as $obj) {
+ if($obj->isNew()) {
+ $collMessageDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collMessageDescs = $collMessageDescs;
+ $this->collMessageDescsPartial = false;
+ }
+ }
+
+ return $this->collMessageDescs;
+ }
+
+ /**
+ * Sets a collection of MessageDesc 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 $messageDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setMessageDescs(PropelCollection $messageDescs, PropelPDO $con = null)
+ {
+ $this->messageDescsScheduledForDeletion = $this->getMessageDescs(new Criteria(), $con)->diff($messageDescs);
+
+ foreach ($this->messageDescsScheduledForDeletion as $messageDescRemoved) {
+ $messageDescRemoved->setMessage(null);
+ }
+
+ $this->collMessageDescs = null;
+ foreach ($messageDescs as $messageDesc) {
+ $this->addMessageDesc($messageDesc);
+ }
+
+ $this->collMessageDescs = $messageDescs;
+ $this->collMessageDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related MessageDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related MessageDesc objects.
+ * @throws PropelException
+ */
+ public function countMessageDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collMessageDescsPartial && !$this->isNew();
+ if (null === $this->collMessageDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collMessageDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getMessageDescs());
+ }
+ $query = MessageDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByMessage($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getMessageId());
+ return count($this->collMessageDescs);
}
+ }
- $this->aMessageDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setMessage($this);
+ /**
+ * Method called to associate a MessageDesc object to this object
+ * through the MessageDesc foreign key attribute.
+ *
+ * @param MessageDesc $l MessageDesc
+ * @return Message The current object (for fluent API support)
+ */
+ public function addMessageDesc(MessageDesc $l)
+ {
+ if ($this->collMessageDescs === null) {
+ $this->initMessageDescs();
+ $this->collMessageDescsPartial = true;
+ }
+ if (!$this->collMessageDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddMessageDesc($l);
}
-
return $this;
}
+ /**
+ * @param MessageDesc $messageDesc The messageDesc object to add.
+ */
+ protected function doAddMessageDesc($messageDesc)
+ {
+ $this->collMessageDescs[]= $messageDesc;
+ $messageDesc->setMessage($this);
+ }
/**
- * Get the associated MessageDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return MessageDesc The associated MessageDesc object.
- * @throws PropelException
+ * @param MessageDesc $messageDesc The messageDesc object to remove.
*/
- public function getMessageDesc(PropelPDO $con = null)
+ public function removeMessageDesc($messageDesc)
{
- if ($this->aMessageDesc === null && ($this->id !== null)) {
- $this->aMessageDesc = MessageDescQuery::create()
- ->filterByMessage($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aMessageDesc->setMessage($this);
+ if ($this->getMessageDescs()->contains($messageDesc)) {
+ $this->collMessageDescs->remove($this->collMessageDescs->search($messageDesc));
+ if (null === $this->messageDescsScheduledForDeletion) {
+ $this->messageDescsScheduledForDeletion = clone $this->collMessageDescs;
+ $this->messageDescsScheduledForDeletion->clear();
+ }
+ $this->messageDescsScheduledForDeletion[]= $messageDesc;
+ $messageDesc->setMessage(null);
}
-
- return $this->aMessageDesc;
}
/**
@@ -1128,9 +1309,17 @@ abstract class BaseMessage extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collMessageDescs) {
+ foreach ($this->collMessageDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aMessageDesc = null;
+ if ($this->collMessageDescs instanceof PropelCollection) {
+ $this->collMessageDescs->clearIterator();
+ }
+ $this->collMessageDescs = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseMessageDesc.php b/core/lib/Thelia/Model/om/BaseMessageDesc.php
index f2a5e15f6..12caa4890 100644
--- a/core/lib/Thelia/Model/om/BaseMessageDesc.php
+++ b/core/lib/Thelia/Model/om/BaseMessageDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Message;
use Thelia\Model\MessageDesc;
@@ -98,9 +96,9 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Message one-to-one related Message object
+ * @var Message
*/
- protected $singleMessage;
+ protected $aMessage;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $messagesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -267,6 +259,10 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = MessageDescPeer::MESSAGE_ID;
}
+ if ($this->aMessage !== null && $this->aMessage->getId() !== $v) {
+ $this->aMessage = null;
+ }
+
return $this;
} // setMessageId()
@@ -470,6 +466,9 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aMessage !== null && $this->message_id !== $this->aMessage->getId()) {
+ $this->aMessage = null;
+ }
} // ensureConsistency
/**
@@ -509,8 +508,7 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleMessage = null;
-
+ $this->aMessage = null;
} // if (deep)
}
@@ -624,6 +622,18 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aMessage !== null) {
+ if ($this->aMessage->isModified() || $this->aMessage->isNew()) {
+ $affectedRows += $this->aMessage->save($con);
+ }
+ $this->setMessage($this->aMessage);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -635,21 +645,6 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->messagesScheduledForDeletion !== null) {
- if (!$this->messagesScheduledForDeletion->isEmpty()) {
- MessageQuery::create()
- ->filterByPrimaryKeys($this->messagesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->messagesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleMessage !== null) {
- if (!$this->singleMessage->isDeleted()) {
- $affectedRows += $this->singleMessage->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -829,17 +824,23 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aMessage !== null) {
+ if (!$this->aMessage->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aMessage->getValidationFailures());
+ }
+ }
+
+
if (($retval = MessageDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleMessage !== null) {
- if (!$this->singleMessage->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleMessage->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -938,8 +939,8 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleMessage) {
- $result['Message'] = $this->singleMessage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aMessage) {
+ $result['Message'] = $this->aMessage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1128,11 +1129,6 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getMessage();
- if ($relObj) {
- $copyObj->setMessage($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1183,55 +1179,57 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Message object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Message object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Message
- * @throws PropelException
- */
- public function getMessage(PropelPDO $con = null)
- {
-
- if ($this->singleMessage === null && !$this->isNew()) {
- $this->singleMessage = MessageQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleMessage;
- }
-
- /**
- * Sets a single Message object as related to this object by a one-to-one relationship.
- *
- * @param Message $v Message
+ * @param Message $v
* @return MessageDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setMessage(Message $v = null)
{
- $this->singleMessage = $v;
-
- // Make sure that that the passed-in Message isn't already associated with this object
- if ($v !== null && $v->getMessageDesc() === null) {
- $v->setMessageDesc($this);
+ if ($v === null) {
+ $this->setMessageId(NULL);
+ } else {
+ $this->setMessageId($v->getId());
}
+ $this->aMessage = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Message object, it will not be re-added.
+ if ($v !== null) {
+ $v->addMessageDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Message object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Message The associated Message object.
+ * @throws PropelException
+ */
+ public function getMessage(PropelPDO $con = null)
+ {
+ if ($this->aMessage === null && ($this->message_id !== null)) {
+ $this->aMessage = MessageQuery::create()->findPk($this->message_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->aMessage->addMessageDescs($this);
+ */
+ }
+
+ return $this->aMessage;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1265,15 +1263,9 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleMessage) {
- $this->singleMessage->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleMessage instanceof PropelCollection) {
- $this->singleMessage->clearIterator();
- }
- $this->singleMessage = null;
+ $this->aMessage = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseMessageDescPeer.php b/core/lib/Thelia/Model/om/BaseMessageDescPeer.php
index 047a2431e..ec5f519ff 100644
--- a/core/lib/Thelia/Model/om/BaseMessageDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseMessageDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseMessageDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'message_desc';
@@ -398,9 +398,6 @@ abstract class BaseMessageDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in MessagePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- MessagePeer::clearInstancePool();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseMessageDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Message table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinMessage(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(MessageDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ MessageDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(MessageDescPeer::MESSAGE_ID, MessagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of MessageDesc objects pre-filled with their Message objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of MessageDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinMessage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME);
+ }
+
+ MessageDescPeer::addSelectColumns($criteria);
+ $startcol = MessageDescPeer::NUM_HYDRATE_COLUMNS;
+ MessagePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(MessageDescPeer::MESSAGE_ID, MessagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = MessageDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = MessageDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = MessageDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ MessageDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = MessagePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = MessagePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = MessagePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ MessagePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (MessageDesc) to $obj2 (Message)
+ $obj2->addMessageDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(MessageDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ MessageDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(MessageDescPeer::MESSAGE_ID, MessagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of MessageDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of MessageDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME);
+ }
+
+ MessageDescPeer::addSelectColumns($criteria);
+ $startcol2 = MessageDescPeer::NUM_HYDRATE_COLUMNS;
+
+ MessagePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + MessagePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(MessageDescPeer::MESSAGE_ID, MessagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = MessageDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = MessageDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = MessageDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ MessageDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Message rows
+
+ $key2 = MessagePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = MessagePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = MessagePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ MessagePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (MessageDesc) to the collection in $obj2 (Message)
+ $obj2->addMessageDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -630,7 +865,6 @@ abstract class BaseMessageDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += MessageDescPeer::doOnDeleteCascade(new Criteria(MessageDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(MessageDescPeer::TABLE_NAME, $con, MessageDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +898,24 @@ abstract class BaseMessageDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ MessageDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof MessageDesc) { // it's a model object
+ // invalidate the cache for this single object
+ MessageDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(MessageDescPeer::DATABASE_NAME);
$criteria->add(MessageDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ MessageDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,23 +928,6 @@ abstract class BaseMessageDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += MessageDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- MessageDescPeer::clearInstancePool();
- } elseif ($values instanceof MessageDesc) { // it's a model object
- MessageDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- MessageDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
MessageDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -712,39 +939,6 @@ abstract class BaseMessageDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = MessageDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Message objects
- $criteria = new Criteria(MessagePeer::DATABASE_NAME);
-
- $criteria->add(MessagePeer::ID, $obj->getMessageId());
- $affectedRows += MessagePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given MessageDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseMessageDescQuery.php b/core/lib/Thelia/Model/om/BaseMessageDescQuery.php
index bf9c5b080..b5d67bb4e 100644
--- a/core/lib/Thelia/Model/om/BaseMessageDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseMessageDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseMessageDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\MessageDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\MessageDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -283,6 +283,8 @@ abstract class BaseMessageDescQuery extends ModelCriteria
* $query->filterByMessageId(array('min' => 12)); // WHERE message_id > 12
*
*
+ * @see filterByMessage()
+ *
* @param mixed $messageId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -505,7 +507,7 @@ abstract class BaseMessageDescQuery extends ModelCriteria
/**
* Filter the query by a related Message object
*
- * @param Message|PropelObjectCollection $message the related object to use as filter
+ * @param Message|PropelObjectCollection $message The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return MessageDescQuery The current query, for fluid interface
@@ -517,10 +519,12 @@ abstract class BaseMessageDescQuery extends ModelCriteria
return $this
->addUsingAlias(MessageDescPeer::MESSAGE_ID, $message->getId(), $comparison);
} elseif ($message instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useMessageQuery()
- ->filterByPrimaryKeys($message->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(MessageDescPeer::MESSAGE_ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByMessage() only accepts arguments of type Message or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseMessagePeer.php b/core/lib/Thelia/Model/om/BaseMessagePeer.php
index c79fd059e..822db1936 100644
--- a/core/lib/Thelia/Model/om/BaseMessagePeer.php
+++ b/core/lib/Thelia/Model/om/BaseMessagePeer.php
@@ -25,7 +25,7 @@ abstract class BaseMessagePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'message';
@@ -383,6 +383,9 @@ abstract class BaseMessagePeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in MessageDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ MessageDescPeer::clearInstancePool();
}
/**
@@ -479,245 +482,6 @@ abstract class BaseMessagePeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related MessageDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinMessageDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(MessagePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- MessagePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(MessagePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(MessagePeer::ID, MessageDescPeer::MESSAGE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Message objects pre-filled with their MessageDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Message objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinMessageDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(MessagePeer::DATABASE_NAME);
- }
-
- MessagePeer::addSelectColumns($criteria);
- $startcol = MessagePeer::NUM_HYDRATE_COLUMNS;
- MessageDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(MessagePeer::ID, MessageDescPeer::MESSAGE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = MessagePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = MessagePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = MessagePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- MessagePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = MessageDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = MessageDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = MessageDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- MessageDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Message) to $obj2 (MessageDesc)
- // one to one relationship
- $obj1->setMessageDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(MessagePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- MessagePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(MessagePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(MessagePeer::ID, MessageDescPeer::MESSAGE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Message objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Message objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(MessagePeer::DATABASE_NAME);
- }
-
- MessagePeer::addSelectColumns($criteria);
- $startcol2 = MessagePeer::NUM_HYDRATE_COLUMNS;
-
- MessageDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + MessageDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(MessagePeer::ID, MessageDescPeer::MESSAGE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = MessagePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = MessagePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = MessagePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- MessagePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined MessageDesc rows
-
- $key2 = MessageDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = MessageDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = MessageDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- MessageDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Message) to the collection in $obj2 (MessageDesc)
- $obj1->setMessageDesc($obj2);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseMessageQuery.php b/core/lib/Thelia/Model/om/BaseMessageQuery.php
index a4a0af04a..03221281b 100644
--- a/core/lib/Thelia/Model/om/BaseMessageQuery.php
+++ b/core/lib/Thelia/Model/om/BaseMessageQuery.php
@@ -68,7 +68,7 @@ abstract class BaseMessageQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Message', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Message', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -244,8 +244,6 @@ abstract class BaseMessageQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByMessageDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -422,7 +420,7 @@ abstract class BaseMessageQuery extends ModelCriteria
/**
* Filter the query by a related MessageDesc object
*
- * @param MessageDesc|PropelObjectCollection $messageDesc The related object(s) to use as filter
+ * @param MessageDesc|PropelObjectCollection $messageDesc the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return MessageQuery The current query, for fluid interface
@@ -434,12 +432,10 @@ abstract class BaseMessageQuery extends ModelCriteria
return $this
->addUsingAlias(MessagePeer::ID, $messageDesc->getMessageId(), $comparison);
} elseif ($messageDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(MessagePeer::ID, $messageDesc->toKeyValue('PrimaryKey', 'MessageId'), $comparison);
+ ->useMessageDescQuery()
+ ->filterByPrimaryKeys($messageDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByMessageDesc() only accepts arguments of type MessageDesc or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseModule.php b/core/lib/Thelia/Model/om/BaseModule.php
index 4361b65e4..0ba8ad580 100644
--- a/core/lib/Thelia/Model/om/BaseModule.php
+++ b/core/lib/Thelia/Model/om/BaseModule.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\GroupModule;
use Thelia\Model\GroupModuleQuery;
@@ -92,14 +94,16 @@ abstract class BaseModule extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var GroupModule
+ * @var PropelObjectCollection|GroupModule[] Collection to store aggregation of GroupModule objects.
*/
- protected $aGroupModule;
+ protected $collGroupModules;
+ protected $collGroupModulesPartial;
/**
- * @var ModuleDesc
+ * @var PropelObjectCollection|ModuleDesc[] Collection to store aggregation of ModuleDesc objects.
*/
- protected $aModuleDesc;
+ protected $collModuleDescs;
+ protected $collModuleDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -115,6 +119,18 @@ abstract class BaseModule extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $groupModulesScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $moduleDescsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -256,14 +272,6 @@ abstract class BaseModule extends BaseObject implements Persistent
$this->modifiedColumns[] = ModulePeer::ID;
}
- if ($this->aGroupModule !== null && $this->aGroupModule->getModuleId() !== $v) {
- $this->aGroupModule = null;
- }
-
- if ($this->aModuleDesc !== null && $this->aModuleDesc->getModuleId() !== $v) {
- $this->aModuleDesc = null;
- }
-
return $this;
} // setId()
@@ -468,12 +476,6 @@ abstract class BaseModule extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aGroupModule !== null && $this->id !== $this->aGroupModule->getModuleId()) {
- $this->aGroupModule = null;
- }
- if ($this->aModuleDesc !== null && $this->id !== $this->aModuleDesc->getModuleId()) {
- $this->aModuleDesc = null;
- }
} // ensureConsistency
/**
@@ -513,8 +515,10 @@ abstract class BaseModule extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aGroupModule = null;
- $this->aModuleDesc = null;
+ $this->collGroupModules = null;
+
+ $this->collModuleDescs = null;
+
} // if (deep)
}
@@ -628,25 +632,6 @@ abstract class BaseModule extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aGroupModule !== null) {
- if ($this->aGroupModule->isModified() || $this->aGroupModule->isNew()) {
- $affectedRows += $this->aGroupModule->save($con);
- }
- $this->setGroupModule($this->aGroupModule);
- }
-
- if ($this->aModuleDesc !== null) {
- if ($this->aModuleDesc->isModified() || $this->aModuleDesc->isNew()) {
- $affectedRows += $this->aModuleDesc->save($con);
- }
- $this->setModuleDesc($this->aModuleDesc);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -658,6 +643,41 @@ abstract class BaseModule extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->groupModulesScheduledForDeletion !== null) {
+ if (!$this->groupModulesScheduledForDeletion->isEmpty()) {
+ foreach ($this->groupModulesScheduledForDeletion as $groupModule) {
+ // need to save related object because we set the relation to null
+ $groupModule->save($con);
+ }
+ $this->groupModulesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collGroupModules !== null) {
+ foreach ($this->collGroupModules as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ 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;
}
@@ -820,29 +840,27 @@ abstract class BaseModule extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aGroupModule !== null) {
- if (!$this->aGroupModule->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aGroupModule->getValidationFailures());
- }
- }
-
- if ($this->aModuleDesc !== null) {
- if (!$this->aModuleDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aModuleDesc->getValidationFailures());
- }
- }
-
-
if (($retval = ModulePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collGroupModules !== null) {
+ foreach ($this->collGroupModules as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collModuleDescs !== null) {
+ foreach ($this->collModuleDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -937,11 +955,11 @@ abstract class BaseModule extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aGroupModule) {
- $result['GroupModule'] = $this->aGroupModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collGroupModules) {
+ $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aModuleDesc) {
- $result['ModuleDesc'] = $this->aModuleDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collModuleDescs) {
+ $result['ModuleDescs'] = $this->collModuleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1124,14 +1142,16 @@ abstract class BaseModule extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getGroupModule();
- if ($relObj) {
- $copyObj->setGroupModule($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));
+ }
}
- $relObj = $this->getModuleDesc();
- if ($relObj) {
- $copyObj->setModuleDesc($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));
+ }
}
//unflag object copy
@@ -1184,98 +1204,462 @@ abstract class BaseModule extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a GroupModule object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param GroupModule $v
- * @return Module The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('GroupModule' == $relationName) {
+ $this->initGroupModules();
+ }
+ if ('ModuleDesc' == $relationName) {
+ $this->initModuleDescs();
+ }
+ }
+
+ /**
+ * Clears out the collGroupModules 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 addGroupModules()
+ */
+ public function clearGroupModules()
+ {
+ $this->collGroupModules = null; // important to set this to null since that means it is uninitialized
+ $this->collGroupModulesPartial = null;
+ }
+
+ /**
+ * reset is the collGroupModules collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialGroupModules($v = true)
+ {
+ $this->collGroupModulesPartial = $v;
+ }
+
+ /**
+ * Initializes the collGroupModules collection.
+ *
+ * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules());
+ * 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 initGroupModules($overrideExisting = true)
+ {
+ if (null !== $this->collGroupModules && !$overrideExisting) {
+ return;
+ }
+ $this->collGroupModules = new PropelObjectCollection();
+ $this->collGroupModules->setModel('GroupModule');
+ }
+
+ /**
+ * Gets an array of GroupModule 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|GroupModule[] List of GroupModule objects
* @throws PropelException
*/
- public function setGroupModule(GroupModule $v = null)
+ public function getGroupModules($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collGroupModulesPartial && !$this->isNew();
+ if (null === $this->collGroupModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupModules) {
+ // return empty collection
+ $this->initGroupModules();
+ } else {
+ $collGroupModules = GroupModuleQuery::create(null, $criteria)
+ ->filterByModule($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collGroupModulesPartial && count($collGroupModules)) {
+ $this->initGroupModules(false);
+
+ foreach($collGroupModules as $obj) {
+ if (false == $this->collGroupModules->contains($obj)) {
+ $this->collGroupModules->append($obj);
+ }
+ }
+
+ $this->collGroupModulesPartial = true;
+ }
+
+ return $collGroupModules;
+ }
+
+ if($partial && $this->collGroupModules) {
+ foreach($this->collGroupModules as $obj) {
+ if($obj->isNew()) {
+ $collGroupModules[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupModules = $collGroupModules;
+ $this->collGroupModulesPartial = false;
+ }
+ }
+
+ return $this->collGroupModules;
+ }
+
+ /**
+ * Sets a collection of GroupModule 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 $groupModules A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null)
+ {
+ $this->groupModulesScheduledForDeletion = $this->getGroupModules(new Criteria(), $con)->diff($groupModules);
+
+ foreach ($this->groupModulesScheduledForDeletion as $groupModuleRemoved) {
+ $groupModuleRemoved->setModule(null);
+ }
+
+ $this->collGroupModules = null;
+ foreach ($groupModules as $groupModule) {
+ $this->addGroupModule($groupModule);
+ }
+
+ $this->collGroupModules = $groupModules;
+ $this->collGroupModulesPartial = false;
+ }
+
+ /**
+ * Returns the number of related GroupModule objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related GroupModule objects.
+ * @throws PropelException
+ */
+ public function countGroupModules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collGroupModulesPartial && !$this->isNew();
+ if (null === $this->collGroupModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupModules) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getGroupModules());
+ }
+ $query = GroupModuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByModule($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getModuleId());
+ return count($this->collGroupModules);
}
+ }
- $this->aGroupModule = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setModule($this);
+ /**
+ * Method called to associate a GroupModule object to this object
+ * through the GroupModule foreign key attribute.
+ *
+ * @param GroupModule $l GroupModule
+ * @return Module The current object (for fluent API support)
+ */
+ public function addGroupModule(GroupModule $l)
+ {
+ if ($this->collGroupModules === null) {
+ $this->initGroupModules();
+ $this->collGroupModulesPartial = true;
+ }
+ if (!$this->collGroupModules->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupModule($l);
}
-
return $this;
}
-
/**
- * Get the associated GroupModule object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return GroupModule The associated GroupModule object.
- * @throws PropelException
+ * @param GroupModule $groupModule The groupModule object to add.
*/
- public function getGroupModule(PropelPDO $con = null)
+ protected function doAddGroupModule($groupModule)
{
- if ($this->aGroupModule === null && ($this->id !== null)) {
- $this->aGroupModule = GroupModuleQuery::create()
- ->filterByModule($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aGroupModule->setModule($this);
- }
-
- return $this->aGroupModule;
+ $this->collGroupModules[]= $groupModule;
+ $groupModule->setModule($this);
}
/**
- * Declares an association between this object and a ModuleDesc object.
+ * @param GroupModule $groupModule The groupModule object to remove.
+ */
+ public function removeGroupModule($groupModule)
+ {
+ if ($this->getGroupModules()->contains($groupModule)) {
+ $this->collGroupModules->remove($this->collGroupModules->search($groupModule));
+ if (null === $this->groupModulesScheduledForDeletion) {
+ $this->groupModulesScheduledForDeletion = clone $this->collGroupModules;
+ $this->groupModulesScheduledForDeletion->clear();
+ }
+ $this->groupModulesScheduledForDeletion[]= $groupModule;
+ $groupModule->setModule(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Module is new, it will return
+ * an empty collection; or if this Module has previously
+ * been saved, it will retrieve related GroupModules from storage.
*
- * @param ModuleDesc $v
- * @return Module The current object (for fluent API support)
+ * 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 Module.
+ *
+ * @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|GroupModule[] List of GroupModule objects
+ */
+ public function getGroupModulesJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = GroupModuleQuery::create(null, $criteria);
+ $query->joinWith('Group', $join_behavior);
+
+ 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 setModuleDesc(ModuleDesc $v = null)
+ public function getModuleDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getModuleId());
+ return count($this->collModuleDescs);
}
+ }
- $this->aModuleDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setModule($this);
+ /**
+ * 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);
+ }
/**
- * Get the associated ModuleDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ModuleDesc The associated ModuleDesc object.
- * @throws PropelException
+ * @param ModuleDesc $moduleDesc The moduleDesc object to remove.
*/
- public function getModuleDesc(PropelPDO $con = null)
+ public function removeModuleDesc($moduleDesc)
{
- if ($this->aModuleDesc === null && ($this->id !== null)) {
- $this->aModuleDesc = ModuleDescQuery::create()
- ->filterByModule($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aModuleDesc->setModule($this);
+ 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);
}
-
- return $this->aModuleDesc;
}
/**
@@ -1310,10 +1694,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 ($deep)
- $this->aGroupModule = null;
- $this->aModuleDesc = null;
+ if ($this->collGroupModules instanceof PropelCollection) {
+ $this->collGroupModules->clearIterator();
+ }
+ $this->collGroupModules = null;
+ if ($this->collModuleDescs instanceof PropelCollection) {
+ $this->collModuleDescs->clearIterator();
+ }
+ $this->collModuleDescs = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseModuleDesc.php b/core/lib/Thelia/Model/om/BaseModuleDesc.php
index a670fba0c..476dbc2b3 100644
--- a/core/lib/Thelia/Model/om/BaseModuleDesc.php
+++ b/core/lib/Thelia/Model/om/BaseModuleDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Module;
use Thelia\Model\ModuleDesc;
@@ -104,9 +102,9 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Module one-to-one related Module object
+ * @var Module
*/
- protected $singleModule;
+ protected $aModule;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -122,12 +120,6 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $modulesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -310,6 +302,10 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = ModuleDescPeer::MODULE_ID;
}
+ if ($this->aModule !== null && $this->aModule->getId() !== $v) {
+ $this->aModule = null;
+ }
+
return $this;
} // setModuleId()
@@ -537,6 +533,9 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) {
+ $this->aModule = null;
+ }
} // ensureConsistency
/**
@@ -576,8 +575,7 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleModule = null;
-
+ $this->aModule = null;
} // if (deep)
}
@@ -691,6 +689,18 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aModule !== null) {
+ if ($this->aModule->isModified() || $this->aModule->isNew()) {
+ $affectedRows += $this->aModule->save($con);
+ }
+ $this->setModule($this->aModule);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -702,21 +712,6 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->modulesScheduledForDeletion !== null) {
- if (!$this->modulesScheduledForDeletion->isEmpty()) {
- ModuleQuery::create()
- ->filterByPrimaryKeys($this->modulesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->modulesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleModule !== null) {
- if (!$this->singleModule->isDeleted()) {
- $affectedRows += $this->singleModule->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -902,17 +897,23 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aModule !== null) {
+ if (!$this->aModule->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aModule->getValidationFailures());
+ }
+ }
+
+
if (($retval = ModuleDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleModule !== null) {
- if (!$this->singleModule->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleModule->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -1015,8 +1016,8 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
$keys[8] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleModule) {
- $result['Module'] = $this->singleModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aModule) {
+ $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1211,11 +1212,6 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getModule();
- if ($relObj) {
- $copyObj->setModule($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1266,55 +1262,57 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Module object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Module object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Module
- * @throws PropelException
- */
- public function getModule(PropelPDO $con = null)
- {
-
- if ($this->singleModule === null && !$this->isNew()) {
- $this->singleModule = ModuleQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleModule;
- }
-
- /**
- * Sets a single Module object as related to this object by a one-to-one relationship.
- *
- * @param Module $v Module
+ * @param Module $v
* @return ModuleDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setModule(Module $v = null)
{
- $this->singleModule = $v;
-
- // Make sure that that the passed-in Module isn't already associated with this object
- if ($v !== null && $v->getModuleDesc() === null) {
- $v->setModuleDesc($this);
+ if ($v === null) {
+ $this->setModuleId(NULL);
+ } else {
+ $this->setModuleId($v->getId());
}
+ $this->aModule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Module object, it will not be re-added.
+ if ($v !== null) {
+ $v->addModuleDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Module object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Module The associated Module object.
+ * @throws PropelException
+ */
+ public function getModule(PropelPDO $con = null)
+ {
+ if ($this->aModule === null && ($this->module_id !== null)) {
+ $this->aModule = ModuleQuery::create()->findPk($this->module_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->aModule->addModuleDescs($this);
+ */
+ }
+
+ return $this->aModule;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1349,15 +1347,9 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleModule) {
- $this->singleModule->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleModule instanceof PropelCollection) {
- $this->singleModule->clearIterator();
- }
- $this->singleModule = null;
+ $this->aModule = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseModuleDescPeer.php b/core/lib/Thelia/Model/om/BaseModuleDescPeer.php
index c0ca4f104..c6c1dbb3e 100644
--- a/core/lib/Thelia/Model/om/BaseModuleDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseModuleDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseModuleDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'module_desc';
@@ -403,9 +403,6 @@ abstract class BaseModuleDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in ModulePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ModulePeer::clearInstancePool();
}
/**
@@ -502,6 +499,244 @@ abstract class BaseModuleDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Module table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinModule(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ModuleDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ModuleDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ModuleDescPeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ModuleDesc objects pre-filled with their Module objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ModuleDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME);
+ }
+
+ ModuleDescPeer::addSelectColumns($criteria);
+ $startcol = ModuleDescPeer::NUM_HYDRATE_COLUMNS;
+ ModulePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ModuleDescPeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ModuleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ModuleDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ModuleDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ModuleDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ModulePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ModulePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ModulePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ModuleDesc) to $obj2 (Module)
+ $obj2->addModuleDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ModuleDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ModuleDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ModuleDescPeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ModuleDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ModuleDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME);
+ }
+
+ ModuleDescPeer::addSelectColumns($criteria);
+ $startcol2 = ModuleDescPeer::NUM_HYDRATE_COLUMNS;
+
+ ModulePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ModulePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ModuleDescPeer::MODULE_ID, ModulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ModuleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ModuleDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ModuleDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ModuleDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Module rows
+
+ $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ModulePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ModulePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ModulePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ModuleDesc) to the collection in $obj2 (Module)
+ $obj2->addModuleDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -635,7 +870,6 @@ abstract class BaseModuleDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ModuleDescPeer::doOnDeleteCascade(new Criteria(ModuleDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ModuleDescPeer::TABLE_NAME, $con, ModuleDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -669,14 +903,24 @@ abstract class BaseModuleDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ModuleDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ModuleDesc) { // it's a model object
+ // invalidate the cache for this single object
+ ModuleDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ModuleDescPeer::DATABASE_NAME);
$criteria->add(ModuleDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ModuleDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -689,23 +933,6 @@ abstract class BaseModuleDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ModuleDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ModuleDescPeer::clearInstancePool();
- } elseif ($values instanceof ModuleDesc) { // it's a model object
- ModuleDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ModuleDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ModuleDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -717,39 +944,6 @@ abstract class BaseModuleDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ModuleDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Module objects
- $criteria = new Criteria(ModulePeer::DATABASE_NAME);
-
- $criteria->add(ModulePeer::ID, $obj->getModuleId());
- $affectedRows += ModulePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ModuleDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseModuleDescQuery.php b/core/lib/Thelia/Model/om/BaseModuleDescQuery.php
index 7fc5540a3..8d477930c 100644
--- a/core/lib/Thelia/Model/om/BaseModuleDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseModuleDescQuery.php
@@ -84,7 +84,7 @@ abstract class BaseModuleDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ModuleDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ModuleDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -287,6 +287,8 @@ abstract class BaseModuleDescQuery extends ModelCriteria
* $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
*
*
+ * @see filterByModule()
+ *
* @param mixed $moduleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -564,7 +566,7 @@ abstract class BaseModuleDescQuery extends ModelCriteria
/**
* Filter the query by a related Module object
*
- * @param Module|PropelObjectCollection $module the related object to use as filter
+ * @param Module|PropelObjectCollection $module The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ModuleDescQuery The current query, for fluid interface
@@ -576,10 +578,12 @@ abstract class BaseModuleDescQuery extends ModelCriteria
return $this
->addUsingAlias(ModuleDescPeer::MODULE_ID, $module->getId(), $comparison);
} elseif ($module instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useModuleQuery()
- ->filterByPrimaryKeys($module->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ModuleDescPeer::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByModule() only accepts arguments of type Module or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseModulePeer.php b/core/lib/Thelia/Model/om/BaseModulePeer.php
index 204fbeb3f..6a4ce8b36 100644
--- a/core/lib/Thelia/Model/om/BaseModulePeer.php
+++ b/core/lib/Thelia/Model/om/BaseModulePeer.php
@@ -26,7 +26,7 @@ abstract class BaseModulePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'module';
@@ -394,6 +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();
}
/**
@@ -490,639 +496,6 @@ abstract class BaseModulePeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupModule table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinGroupModule(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ModulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ModulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ModulePeer::ID, GroupModulePeer::MODULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ModuleDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinModuleDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ModulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ModulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ModulePeer::ID, ModuleDescPeer::MODULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Module objects pre-filled with their GroupModule objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Module objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinGroupModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
- }
-
- ModulePeer::addSelectColumns($criteria);
- $startcol = ModulePeer::NUM_HYDRATE_COLUMNS;
- GroupModulePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ModulePeer::ID, GroupModulePeer::MODULE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ModulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ModulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ModulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ModulePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = GroupModulePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupModulePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- GroupModulePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Module) to $obj2 (GroupModule)
- // one to one relationship
- $obj1->setGroupModule($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Module objects pre-filled with their ModuleDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Module objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinModuleDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
- }
-
- ModulePeer::addSelectColumns($criteria);
- $startcol = ModulePeer::NUM_HYDRATE_COLUMNS;
- ModuleDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ModulePeer::ID, ModuleDescPeer::MODULE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ModulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ModulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ModulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ModulePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ModuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ModuleDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ModuleDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ModuleDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Module) to $obj2 (ModuleDesc)
- // one to one relationship
- $obj1->setModuleDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ModulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ModulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ModulePeer::ID, GroupModulePeer::MODULE_ID, $join_behavior);
-
- $criteria->addJoin(ModulePeer::ID, ModuleDescPeer::MODULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Module objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Module objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
- }
-
- ModulePeer::addSelectColumns($criteria);
- $startcol2 = ModulePeer::NUM_HYDRATE_COLUMNS;
-
- GroupModulePeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + GroupModulePeer::NUM_HYDRATE_COLUMNS;
-
- ModuleDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ModuleDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ModulePeer::ID, GroupModulePeer::MODULE_ID, $join_behavior);
-
- $criteria->addJoin(ModulePeer::ID, ModuleDescPeer::MODULE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ModulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ModulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ModulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ModulePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined GroupModule rows
-
- $key2 = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = GroupModulePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupModulePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- GroupModulePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Module) to the collection in $obj2 (GroupModule)
- $obj1->setGroupModule($obj2);
- } // if joined row not null
-
- // Add objects for joined ModuleDesc rows
-
- $key3 = ModuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ModuleDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ModuleDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ModuleDescPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Module) to the collection in $obj3 (ModuleDesc)
- $obj1->setModuleDesc($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupModule table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptGroupModule(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ModulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ModulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ModulePeer::ID, ModuleDescPeer::MODULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ModuleDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptModuleDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ModulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ModulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ModulePeer::ID, GroupModulePeer::MODULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Module objects pre-filled with all related objects except GroupModule.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Module objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptGroupModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
- }
-
- ModulePeer::addSelectColumns($criteria);
- $startcol2 = ModulePeer::NUM_HYDRATE_COLUMNS;
-
- ModuleDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ModuleDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ModulePeer::ID, ModuleDescPeer::MODULE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ModulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ModulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ModulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ModulePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ModuleDesc rows
-
- $key2 = ModuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ModuleDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ModuleDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ModuleDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Module) to the collection in $obj2 (ModuleDesc)
- $obj1->setModuleDesc($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Module objects pre-filled with all related objects except ModuleDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Module objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptModuleDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ModulePeer::DATABASE_NAME);
- }
-
- ModulePeer::addSelectColumns($criteria);
- $startcol2 = ModulePeer::NUM_HYDRATE_COLUMNS;
-
- GroupModulePeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + GroupModulePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ModulePeer::ID, GroupModulePeer::MODULE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ModulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ModulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ModulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ModulePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined GroupModule rows
-
- $key2 = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = GroupModulePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupModulePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- GroupModulePeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Module) to the collection in $obj2 (GroupModule)
- $obj1->setGroupModule($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseModuleQuery.php b/core/lib/Thelia/Model/om/BaseModuleQuery.php
index 8e57d19da..66d427021 100644
--- a/core/lib/Thelia/Model/om/BaseModuleQuery.php
+++ b/core/lib/Thelia/Model/om/BaseModuleQuery.php
@@ -81,7 +81,7 @@ abstract class BaseModuleQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Module', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Module', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -257,10 +257,6 @@ abstract class BaseModuleQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByGroupModule()
- *
- * @see filterByModuleDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +515,7 @@ abstract class BaseModuleQuery extends ModelCriteria
/**
* Filter the query by a related GroupModule object
*
- * @param GroupModule|PropelObjectCollection $groupModule The related object(s) to use as filter
+ * @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
@@ -531,12 +527,10 @@ abstract class BaseModuleQuery extends ModelCriteria
return $this
->addUsingAlias(ModulePeer::ID, $groupModule->getModuleId(), $comparison);
} elseif ($groupModule instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ModulePeer::ID, $groupModule->toKeyValue('PrimaryKey', 'ModuleId'), $comparison);
+ ->useGroupModuleQuery()
+ ->filterByPrimaryKeys($groupModule->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection');
}
@@ -550,7 +544,7 @@ abstract class BaseModuleQuery extends ModelCriteria
*
* @return ModuleQuery The current query, for fluid interface
*/
- public function joinGroupModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinGroupModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('GroupModule');
@@ -585,7 +579,7 @@ abstract class BaseModuleQuery extends ModelCriteria
*
* @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query
*/
- public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinGroupModule($relationAlias, $joinType)
@@ -595,7 +589,7 @@ abstract class BaseModuleQuery extends ModelCriteria
/**
* Filter the query by a related ModuleDesc object
*
- * @param ModuleDesc|PropelObjectCollection $moduleDesc The related object(s) to use as filter
+ * @param ModuleDesc|PropelObjectCollection $moduleDesc 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
@@ -607,12 +601,10 @@ abstract class BaseModuleQuery extends ModelCriteria
return $this
->addUsingAlias(ModulePeer::ID, $moduleDesc->getModuleId(), $comparison);
} elseif ($moduleDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ModulePeer::ID, $moduleDesc->toKeyValue('PrimaryKey', 'ModuleId'), $comparison);
+ ->useModuleDescQuery()
+ ->filterByPrimaryKeys($moduleDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByModuleDesc() only accepts arguments of type ModuleDesc or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseOrder.php b/core/lib/Thelia/Model/om/BaseOrder.php
index 049700700..199a7f43d 100644
--- a/core/lib/Thelia/Model/om/BaseOrder.php
+++ b/core/lib/Thelia/Model/om/BaseOrder.php
@@ -168,39 +168,41 @@ abstract class BaseOrder extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var CouponOrder
+ * @var Currency
*/
- protected $aCouponOrder;
+ protected $aCurrency;
/**
- * @var OrderProduct
+ * @var Customer
*/
- protected $aOrderProduct;
+ protected $aCustomer;
/**
- * @var Currency one-to-one related Currency object
+ * @var OrderAddress
*/
- protected $singleCurrency;
+ protected $aOrderAddressRelatedByAddressInvoice;
/**
- * @var Customer one-to-one related Customer object
+ * @var OrderAddress
*/
- protected $singleCustomer;
+ protected $aOrderAddressRelatedByAddressDelivery;
/**
- * @var OrderAddress one-to-one related OrderAddress object
+ * @var OrderStatus
*/
- protected $singleOrderAddress;
+ protected $aOrderStatus;
/**
- * @var OrderAddress one-to-one related OrderAddress object
+ * @var PropelObjectCollection|CouponOrder[] Collection to store aggregation of CouponOrder objects.
*/
- protected $singleOrderAddress;
+ protected $collCouponOrders;
+ protected $collCouponOrdersPartial;
/**
- * @var OrderStatus one-to-one related OrderStatus object
+ * @var PropelObjectCollection|OrderProduct[] Collection to store aggregation of OrderProduct objects.
*/
- protected $singleOrderStatus;
+ protected $collOrderProducts;
+ protected $collOrderProductsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -220,31 +222,13 @@ abstract class BaseOrder extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $currencysScheduledForDeletion = null;
+ protected $couponOrdersScheduledForDeletion = null;
/**
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $customersScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $orderAddresssScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $orderAddresssScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $orderStatussScheduledForDeletion = null;
+ protected $orderProductsScheduledForDeletion = null;
/**
* Get the [id] column value.
@@ -524,14 +508,6 @@ abstract class BaseOrder extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderPeer::ID;
}
- if ($this->aCouponOrder !== null && $this->aCouponOrder->getOrderId() !== $v) {
- $this->aCouponOrder = null;
- }
-
- if ($this->aOrderProduct !== null && $this->aOrderProduct->getOrderId() !== $v) {
- $this->aOrderProduct = null;
- }
-
return $this;
} // setId()
@@ -574,6 +550,10 @@ abstract class BaseOrder extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderPeer::CUSTOMER_ID;
}
+ if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
+ $this->aCustomer = null;
+ }
+
return $this;
} // setCustomerId()
@@ -595,6 +575,10 @@ abstract class BaseOrder extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderPeer::ADDRESS_INVOICE;
}
+ if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->aOrderAddressRelatedByAddressInvoice->getId() !== $v) {
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ }
+
return $this;
} // setAddressInvoice()
@@ -616,6 +600,10 @@ abstract class BaseOrder extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderPeer::ADDRESS_DELIVERY;
}
+ if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->aOrderAddressRelatedByAddressDelivery->getId() !== $v) {
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ }
+
return $this;
} // setAddressDelivery()
@@ -660,6 +648,10 @@ abstract class BaseOrder extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderPeer::CURRENCY_ID;
}
+ if ($this->aCurrency !== null && $this->aCurrency->getId() !== $v) {
+ $this->aCurrency = null;
+ }
+
return $this;
} // setCurrencyId()
@@ -828,6 +820,10 @@ abstract class BaseOrder extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderPeer::STATUS_ID;
}
+ if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) {
+ $this->aOrderStatus = null;
+ }
+
return $this;
} // setStatusId()
@@ -980,11 +976,20 @@ abstract class BaseOrder extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aCouponOrder !== null && $this->id !== $this->aCouponOrder->getOrderId()) {
- $this->aCouponOrder = null;
+ if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
+ $this->aCustomer = null;
}
- if ($this->aOrderProduct !== null && $this->id !== $this->aOrderProduct->getOrderId()) {
- $this->aOrderProduct = null;
+ if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->address_invoice !== $this->aOrderAddressRelatedByAddressInvoice->getId()) {
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ }
+ if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->address_delivery !== $this->aOrderAddressRelatedByAddressDelivery->getId()) {
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ }
+ if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) {
+ $this->aCurrency = null;
+ }
+ if ($this->aOrderStatus !== null && $this->status_id !== $this->aOrderStatus->getId()) {
+ $this->aOrderStatus = null;
}
} // ensureConsistency
@@ -1025,17 +1030,14 @@ abstract class BaseOrder extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aCouponOrder = null;
- $this->aOrderProduct = null;
- $this->singleCurrency = null;
+ $this->aCurrency = null;
+ $this->aCustomer = null;
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ $this->aOrderStatus = null;
+ $this->collCouponOrders = null;
- $this->singleCustomer = null;
-
- $this->singleOrderAddress = null;
-
- $this->singleOrderAddress = null;
-
- $this->singleOrderStatus = null;
+ $this->collOrderProducts = null;
} // if (deep)
}
@@ -1155,18 +1157,39 @@ abstract class BaseOrder extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aCouponOrder !== null) {
- if ($this->aCouponOrder->isModified() || $this->aCouponOrder->isNew()) {
- $affectedRows += $this->aCouponOrder->save($con);
+ if ($this->aCurrency !== null) {
+ if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) {
+ $affectedRows += $this->aCurrency->save($con);
}
- $this->setCouponOrder($this->aCouponOrder);
+ $this->setCurrency($this->aCurrency);
}
- if ($this->aOrderProduct !== null) {
- if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) {
- $affectedRows += $this->aOrderProduct->save($con);
+ if ($this->aCustomer !== null) {
+ if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) {
+ $affectedRows += $this->aCustomer->save($con);
}
- $this->setOrderProduct($this->aOrderProduct);
+ $this->setCustomer($this->aCustomer);
+ }
+
+ if ($this->aOrderAddressRelatedByAddressInvoice !== null) {
+ if ($this->aOrderAddressRelatedByAddressInvoice->isModified() || $this->aOrderAddressRelatedByAddressInvoice->isNew()) {
+ $affectedRows += $this->aOrderAddressRelatedByAddressInvoice->save($con);
+ }
+ $this->setOrderAddressRelatedByAddressInvoice($this->aOrderAddressRelatedByAddressInvoice);
+ }
+
+ if ($this->aOrderAddressRelatedByAddressDelivery !== null) {
+ if ($this->aOrderAddressRelatedByAddressDelivery->isModified() || $this->aOrderAddressRelatedByAddressDelivery->isNew()) {
+ $affectedRows += $this->aOrderAddressRelatedByAddressDelivery->save($con);
+ }
+ $this->setOrderAddressRelatedByAddressDelivery($this->aOrderAddressRelatedByAddressDelivery);
+ }
+
+ if ($this->aOrderStatus !== null) {
+ if ($this->aOrderStatus->isModified() || $this->aOrderStatus->isNew()) {
+ $affectedRows += $this->aOrderStatus->save($con);
+ }
+ $this->setOrderStatus($this->aOrderStatus);
}
if ($this->isNew() || $this->isModified()) {
@@ -1180,78 +1203,37 @@ abstract class BaseOrder extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->currencysScheduledForDeletion !== null) {
- if (!$this->currencysScheduledForDeletion->isEmpty()) {
- CurrencyQuery::create()
- ->filterByPrimaryKeys($this->currencysScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->couponOrdersScheduledForDeletion !== null) {
+ if (!$this->couponOrdersScheduledForDeletion->isEmpty()) {
+ CouponOrderQuery::create()
+ ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->currencysScheduledForDeletion = null;
+ $this->couponOrdersScheduledForDeletion = null;
}
}
- if ($this->singleCurrency !== null) {
- if (!$this->singleCurrency->isDeleted()) {
- $affectedRows += $this->singleCurrency->save($con);
+ if ($this->collCouponOrders !== null) {
+ foreach ($this->collCouponOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
}
}
- if ($this->customersScheduledForDeletion !== null) {
- if (!$this->customersScheduledForDeletion->isEmpty()) {
- CustomerQuery::create()
- ->filterByPrimaryKeys($this->customersScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->orderProductsScheduledForDeletion !== null) {
+ if (!$this->orderProductsScheduledForDeletion->isEmpty()) {
+ OrderProductQuery::create()
+ ->filterByPrimaryKeys($this->orderProductsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->customersScheduledForDeletion = null;
+ $this->orderProductsScheduledForDeletion = null;
}
}
- if ($this->singleCustomer !== null) {
- if (!$this->singleCustomer->isDeleted()) {
- $affectedRows += $this->singleCustomer->save($con);
- }
- }
-
- if ($this->orderAddresssScheduledForDeletion !== null) {
- if (!$this->orderAddresssScheduledForDeletion->isEmpty()) {
- OrderAddressQuery::create()
- ->filterByPrimaryKeys($this->orderAddresssScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->orderAddresssScheduledForDeletion = null;
- }
- }
-
- if ($this->singleOrderAddress !== null) {
- if (!$this->singleOrderAddress->isDeleted()) {
- $affectedRows += $this->singleOrderAddress->save($con);
- }
- }
-
- if ($this->orderAddresssScheduledForDeletion !== null) {
- if (!$this->orderAddresssScheduledForDeletion->isEmpty()) {
- OrderAddressQuery::create()
- ->filterByPrimaryKeys($this->orderAddresssScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->orderAddresssScheduledForDeletion = null;
- }
- }
-
- if ($this->singleOrderAddress !== null) {
- if (!$this->singleOrderAddress->isDeleted()) {
- $affectedRows += $this->singleOrderAddress->save($con);
- }
- }
-
- if ($this->orderStatussScheduledForDeletion !== null) {
- if (!$this->orderStatussScheduledForDeletion->isEmpty()) {
- OrderStatusQuery::create()
- ->filterByPrimaryKeys($this->orderStatussScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->orderStatussScheduledForDeletion = null;
- }
- }
-
- if ($this->singleOrderStatus !== null) {
- if (!$this->singleOrderStatus->isDeleted()) {
- $affectedRows += $this->singleOrderStatus->save($con);
+ if ($this->collOrderProducts !== null) {
+ foreach ($this->collOrderProducts as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
}
}
@@ -1499,15 +1481,33 @@ abstract class BaseOrder extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aCouponOrder !== null) {
- if (!$this->aCouponOrder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aCouponOrder->getValidationFailures());
+ if ($this->aCurrency !== null) {
+ if (!$this->aCurrency->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCurrency->getValidationFailures());
}
}
- if ($this->aOrderProduct !== null) {
- if (!$this->aOrderProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aOrderProduct->getValidationFailures());
+ if ($this->aCustomer !== null) {
+ if (!$this->aCustomer->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCustomer->getValidationFailures());
+ }
+ }
+
+ if ($this->aOrderAddressRelatedByAddressInvoice !== null) {
+ if (!$this->aOrderAddressRelatedByAddressInvoice->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aOrderAddressRelatedByAddressInvoice->getValidationFailures());
+ }
+ }
+
+ if ($this->aOrderAddressRelatedByAddressDelivery !== null) {
+ if (!$this->aOrderAddressRelatedByAddressDelivery->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aOrderAddressRelatedByAddressDelivery->getValidationFailures());
+ }
+ }
+
+ if ($this->aOrderStatus !== null) {
+ if (!$this->aOrderStatus->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aOrderStatus->getValidationFailures());
}
}
@@ -1517,33 +1517,19 @@ abstract class BaseOrder extends BaseObject implements Persistent
}
- if ($this->singleCurrency !== null) {
- if (!$this->singleCurrency->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCurrency->getValidationFailures());
+ if ($this->collCouponOrders !== null) {
+ foreach ($this->collCouponOrders as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
}
}
- if ($this->singleCustomer !== null) {
- if (!$this->singleCustomer->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCustomer->getValidationFailures());
- }
- }
-
- if ($this->singleOrderAddress !== null) {
- if (!$this->singleOrderAddress->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleOrderAddress->getValidationFailures());
- }
- }
-
- if ($this->singleOrderAddress !== null) {
- if (!$this->singleOrderAddress->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleOrderAddress->getValidationFailures());
- }
- }
-
- if ($this->singleOrderStatus !== null) {
- if (!$this->singleOrderStatus->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleOrderStatus->getValidationFailures());
+ if ($this->collOrderProducts !== null) {
+ foreach ($this->collOrderProducts as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
}
}
@@ -1685,26 +1671,26 @@ abstract class BaseOrder extends BaseObject implements Persistent
$keys[17] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aCouponOrder) {
- $result['CouponOrder'] = $this->aCouponOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCurrency) {
+ $result['Currency'] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->aOrderProduct) {
- $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCustomer) {
+ $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleCurrency) {
- $result['Currency'] = $this->singleCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aOrderAddressRelatedByAddressInvoice) {
+ $result['OrderAddressRelatedByAddressInvoice'] = $this->aOrderAddressRelatedByAddressInvoice->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleCustomer) {
- $result['Customer'] = $this->singleCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aOrderAddressRelatedByAddressDelivery) {
+ $result['OrderAddressRelatedByAddressDelivery'] = $this->aOrderAddressRelatedByAddressDelivery->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleOrderAddress) {
- $result['OrderAddress'] = $this->singleOrderAddress->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aOrderStatus) {
+ $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleOrderAddress) {
- $result['OrderAddress'] = $this->singleOrderAddress->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collCouponOrders) {
+ $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->singleOrderStatus) {
- $result['OrderStatus'] = $this->singleOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collOrderProducts) {
+ $result['OrderProducts'] = $this->collOrderProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1953,39 +1939,16 @@ abstract class BaseOrder extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCurrency();
- if ($relObj) {
- $copyObj->setCurrency($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));
+ }
}
- $relObj = $this->getCustomer();
- if ($relObj) {
- $copyObj->setCustomer($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getOrderAddress();
- if ($relObj) {
- $copyObj->setOrderAddress($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getOrderAddress();
- if ($relObj) {
- $copyObj->setOrderAddress($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getOrderStatus();
- if ($relObj) {
- $copyObj->setOrderStatus($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getCouponOrder();
- if ($relObj) {
- $copyObj->setCouponOrder($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getOrderProduct();
- if ($relObj) {
- $copyObj->setOrderProduct($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));
+ }
}
//unflag object copy
@@ -2039,25 +2002,26 @@ abstract class BaseOrder extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a CouponOrder object.
+ * Declares an association between this object and a Currency object.
*
- * @param CouponOrder $v
+ * @param Currency $v
* @return Order The current object (for fluent API support)
* @throws PropelException
*/
- public function setCouponOrder(CouponOrder $v = null)
+ public function setCurrency(Currency $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setCurrencyId(NULL);
} else {
- $this->setId($v->getOrderId());
+ $this->setCurrencyId($v->getId());
}
- $this->aCouponOrder = $v;
+ $this->aCurrency = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Currency object, it will not be re-added.
if ($v !== null) {
- $v->setOrder($this);
+ $v->addOrder($this);
}
@@ -2066,45 +2030,49 @@ abstract class BaseOrder extends BaseObject implements Persistent
/**
- * Get the associated CouponOrder object
+ * Get the associated Currency object
*
* @param PropelPDO $con Optional Connection object.
- * @return CouponOrder The associated CouponOrder object.
+ * @return Currency The associated Currency object.
* @throws PropelException
*/
- public function getCouponOrder(PropelPDO $con = null)
+ public function getCurrency(PropelPDO $con = null)
{
- if ($this->aCouponOrder === null && ($this->id !== null)) {
- $this->aCouponOrder = CouponOrderQuery::create()
- ->filterByOrder($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aCouponOrder->setOrder($this);
+ if ($this->aCurrency === null && ($this->currency_id !== null)) {
+ $this->aCurrency = CurrencyQuery::create()->findPk($this->currency_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->aCurrency->addOrders($this);
+ */
}
- return $this->aCouponOrder;
+ return $this->aCurrency;
}
/**
- * Declares an association between this object and a OrderProduct object.
+ * Declares an association between this object and a Customer object.
*
- * @param OrderProduct $v
+ * @param Customer $v
* @return Order The current object (for fluent API support)
* @throws PropelException
*/
- public function setOrderProduct(OrderProduct $v = null)
+ public function setCustomer(Customer $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setCustomerId(NULL);
} else {
- $this->setId($v->getOrderId());
+ $this->setCustomerId($v->getId());
}
- $this->aOrderProduct = $v;
+ $this->aCustomer = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Customer object, it will not be re-added.
if ($v !== null) {
- $v->setOrder($this);
+ $v->addOrder($this);
}
@@ -2113,23 +2081,179 @@ abstract class BaseOrder extends BaseObject implements Persistent
/**
- * Get the associated OrderProduct object
+ * Get the associated Customer object
*
* @param PropelPDO $con Optional Connection object.
- * @return OrderProduct The associated OrderProduct object.
+ * @return Customer The associated Customer object.
* @throws PropelException
*/
- public function getOrderProduct(PropelPDO $con = null)
+ public function getCustomer(PropelPDO $con = null)
{
- if ($this->aOrderProduct === null && ($this->id !== null)) {
- $this->aOrderProduct = OrderProductQuery::create()
- ->filterByOrder($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aOrderProduct->setOrder($this);
+ if ($this->aCustomer === null && ($this->customer_id !== null)) {
+ $this->aCustomer = CustomerQuery::create()->findPk($this->customer_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->aCustomer->addOrders($this);
+ */
}
- return $this->aOrderProduct;
+ return $this->aCustomer;
+ }
+
+ /**
+ * Declares an association between this object and a OrderAddress object.
+ *
+ * @param OrderAddress $v
+ * @return Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderAddressRelatedByAddressInvoice(OrderAddress $v = null)
+ {
+ if ($v === null) {
+ $this->setAddressInvoice(NULL);
+ } else {
+ $this->setAddressInvoice($v->getId());
+ }
+
+ $this->aOrderAddressRelatedByAddressInvoice = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the OrderAddress object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderRelatedByAddressInvoice($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated OrderAddress object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return OrderAddress The associated OrderAddress object.
+ * @throws PropelException
+ */
+ public function getOrderAddressRelatedByAddressInvoice(PropelPDO $con = null)
+ {
+ if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null)) {
+ $this->aOrderAddressRelatedByAddressInvoice = OrderAddressQuery::create()->findPk($this->address_invoice, $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->aOrderAddressRelatedByAddressInvoice->addOrdersRelatedByAddressInvoice($this);
+ */
+ }
+
+ return $this->aOrderAddressRelatedByAddressInvoice;
+ }
+
+ /**
+ * Declares an association between this object and a OrderAddress object.
+ *
+ * @param OrderAddress $v
+ * @return Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderAddressRelatedByAddressDelivery(OrderAddress $v = null)
+ {
+ if ($v === null) {
+ $this->setAddressDelivery(NULL);
+ } else {
+ $this->setAddressDelivery($v->getId());
+ }
+
+ $this->aOrderAddressRelatedByAddressDelivery = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the OrderAddress object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderRelatedByAddressDelivery($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated OrderAddress object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return OrderAddress The associated OrderAddress object.
+ * @throws PropelException
+ */
+ public function getOrderAddressRelatedByAddressDelivery(PropelPDO $con = null)
+ {
+ if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null)) {
+ $this->aOrderAddressRelatedByAddressDelivery = OrderAddressQuery::create()->findPk($this->address_delivery, $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->aOrderAddressRelatedByAddressDelivery->addOrdersRelatedByAddressDelivery($this);
+ */
+ }
+
+ return $this->aOrderAddressRelatedByAddressDelivery;
+ }
+
+ /**
+ * Declares an association between this object and a OrderStatus object.
+ *
+ * @param OrderStatus $v
+ * @return Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderStatus(OrderStatus $v = null)
+ {
+ if ($v === null) {
+ $this->setStatusId(NULL);
+ } else {
+ $this->setStatusId($v->getId());
+ }
+
+ $this->aOrderStatus = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the OrderStatus object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated OrderStatus object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return OrderStatus The associated OrderStatus object.
+ * @throws PropelException
+ */
+ public function getOrderStatus(PropelPDO $con = null)
+ {
+ if ($this->aOrderStatus === null && ($this->status_id !== null)) {
+ $this->aOrderStatus = OrderStatusQuery::create()->findPk($this->status_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->aOrderStatus->addOrders($this);
+ */
+ }
+
+ return $this->aOrderStatus;
}
@@ -2143,186 +2267,426 @@ abstract class BaseOrder extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ if ('CouponOrder' == $relationName) {
+ $this->initCouponOrders();
+ }
+ if ('OrderProduct' == $relationName) {
+ $this->initOrderProducts();
+ }
}
/**
- * Gets a single Currency object, which is related to this object by a one-to-one relationship.
+ * 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 Currency
+ * @return PropelObjectCollection|CouponOrder[] List of CouponOrder objects
* @throws PropelException
*/
- public function getCurrency(PropelPDO $con = null)
+ 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);
- if ($this->singleCurrency === null && !$this->isNew()) {
- $this->singleCurrency = CurrencyQuery::create()->findPk($this->getPrimaryKey(), $con);
+ 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->singleCurrency;
+ return $this->collCouponOrders;
}
/**
- * Sets a single Currency object as related to this object by a one-to-one relationship.
+ * 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 Currency $v Currency
- * @return Order The current object (for fluent API support)
+ * @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 setCurrency(Currency $v = null)
+ public function countCouponOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleCurrency = $v;
+ $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();
+ }
- // Make sure that that the passed-in Currency isn't already associated with this object
- if ($v !== null && $v->getOrder() === null) {
- $v->setOrder($this);
+ 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;
}
/**
- * Gets a single Customer object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Customer
- * @throws PropelException
+ * @param CouponOrder $couponOrder The couponOrder object to add.
*/
- public function getCustomer(PropelPDO $con = null)
+ protected function doAddCouponOrder($couponOrder)
{
-
- if ($this->singleCustomer === null && !$this->isNew()) {
- $this->singleCustomer = CustomerQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCustomer;
+ $this->collCouponOrders[]= $couponOrder;
+ $couponOrder->setOrder($this);
}
/**
- * Sets a single Customer object as related to this object by a one-to-one relationship.
+ * @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 out the collOrderProducts collection
*
- * @param Customer $v Customer
- * @return Order The current object (for fluent API support)
+ * 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 addOrderProducts()
+ */
+ public function clearOrderProducts()
+ {
+ $this->collOrderProducts = null; // important to set this to null since that means it is uninitialized
+ $this->collOrderProductsPartial = null;
+ }
+
+ /**
+ * reset is the collOrderProducts collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialOrderProducts($v = true)
+ {
+ $this->collOrderProductsPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderProducts collection.
+ *
+ * By default this just sets the collOrderProducts collection to an empty array (like clearcollOrderProducts());
+ * 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 initOrderProducts($overrideExisting = true)
+ {
+ if (null !== $this->collOrderProducts && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderProducts = new PropelObjectCollection();
+ $this->collOrderProducts->setModel('OrderProduct');
+ }
+
+ /**
+ * Gets an array of OrderProduct 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|OrderProduct[] List of OrderProduct objects
* @throws PropelException
*/
- public function setCustomer(Customer $v = null)
+ public function getOrderProducts($criteria = null, PropelPDO $con = null)
{
- $this->singleCustomer = $v;
+ $partial = $this->collOrderProductsPartial && !$this->isNew();
+ if (null === $this->collOrderProducts || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderProducts) {
+ // return empty collection
+ $this->initOrderProducts();
+ } else {
+ $collOrderProducts = OrderProductQuery::create(null, $criteria)
+ ->filterByOrder($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collOrderProductsPartial && count($collOrderProducts)) {
+ $this->initOrderProducts(false);
- // Make sure that that the passed-in Customer isn't already associated with this object
- if ($v !== null && $v->getOrder() === null) {
- $v->setOrder($this);
+ foreach($collOrderProducts as $obj) {
+ if (false == $this->collOrderProducts->contains($obj)) {
+ $this->collOrderProducts->append($obj);
+ }
+ }
+
+ $this->collOrderProductsPartial = true;
+ }
+
+ return $collOrderProducts;
+ }
+
+ if($partial && $this->collOrderProducts) {
+ foreach($this->collOrderProducts as $obj) {
+ if($obj->isNew()) {
+ $collOrderProducts[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderProducts = $collOrderProducts;
+ $this->collOrderProductsPartial = false;
+ }
+ }
+
+ return $this->collOrderProducts;
+ }
+
+ /**
+ * Sets a collection of OrderProduct 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 $orderProducts A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setOrderProducts(PropelCollection $orderProducts, PropelPDO $con = null)
+ {
+ $this->orderProductsScheduledForDeletion = $this->getOrderProducts(new Criteria(), $con)->diff($orderProducts);
+
+ foreach ($this->orderProductsScheduledForDeletion as $orderProductRemoved) {
+ $orderProductRemoved->setOrder(null);
+ }
+
+ $this->collOrderProducts = null;
+ foreach ($orderProducts as $orderProduct) {
+ $this->addOrderProduct($orderProduct);
+ }
+
+ $this->collOrderProducts = $orderProducts;
+ $this->collOrderProductsPartial = false;
+ }
+
+ /**
+ * Returns the number of related OrderProduct objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related OrderProduct objects.
+ * @throws PropelException
+ */
+ public function countOrderProducts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collOrderProductsPartial && !$this->isNew();
+ if (null === $this->collOrderProducts || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderProducts) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getOrderProducts());
+ }
+ $query = OrderProductQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrder($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collOrderProducts);
+ }
+ }
+
+ /**
+ * Method called to associate a OrderProduct object to this object
+ * through the OrderProduct foreign key attribute.
+ *
+ * @param OrderProduct $l OrderProduct
+ * @return Order The current object (for fluent API support)
+ */
+ public function addOrderProduct(OrderProduct $l)
+ {
+ if ($this->collOrderProducts === null) {
+ $this->initOrderProducts();
+ $this->collOrderProductsPartial = true;
+ }
+ if (!$this->collOrderProducts->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderProduct($l);
}
return $this;
}
/**
- * Gets a single OrderAddress object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return OrderAddress
- * @throws PropelException
+ * @param OrderProduct $orderProduct The orderProduct object to add.
*/
- public function getOrderAddress(PropelPDO $con = null)
+ protected function doAddOrderProduct($orderProduct)
{
-
- if ($this->singleOrderAddress === null && !$this->isNew()) {
- $this->singleOrderAddress = OrderAddressQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleOrderAddress;
+ $this->collOrderProducts[]= $orderProduct;
+ $orderProduct->setOrder($this);
}
/**
- * Sets a single OrderAddress object as related to this object by a one-to-one relationship.
- *
- * @param OrderAddress $v OrderAddress
- * @return Order The current object (for fluent API support)
- * @throws PropelException
+ * @param OrderProduct $orderProduct The orderProduct object to remove.
*/
- public function setOrderAddress(OrderAddress $v = null)
+ public function removeOrderProduct($orderProduct)
{
- $this->singleOrderAddress = $v;
-
- // Make sure that that the passed-in OrderAddress isn't already associated with this object
- if ($v !== null && $v->getOrder() === null) {
- $v->setOrder($this);
+ if ($this->getOrderProducts()->contains($orderProduct)) {
+ $this->collOrderProducts->remove($this->collOrderProducts->search($orderProduct));
+ if (null === $this->orderProductsScheduledForDeletion) {
+ $this->orderProductsScheduledForDeletion = clone $this->collOrderProducts;
+ $this->orderProductsScheduledForDeletion->clear();
+ }
+ $this->orderProductsScheduledForDeletion[]= $orderProduct;
+ $orderProduct->setOrder(null);
}
-
- return $this;
- }
-
- /**
- * Gets a single OrderAddress object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return OrderAddress
- * @throws PropelException
- */
- public function getOrderAddress(PropelPDO $con = null)
- {
-
- if ($this->singleOrderAddress === null && !$this->isNew()) {
- $this->singleOrderAddress = OrderAddressQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleOrderAddress;
- }
-
- /**
- * Sets a single OrderAddress object as related to this object by a one-to-one relationship.
- *
- * @param OrderAddress $v OrderAddress
- * @return Order The current object (for fluent API support)
- * @throws PropelException
- */
- public function setOrderAddress(OrderAddress $v = null)
- {
- $this->singleOrderAddress = $v;
-
- // Make sure that that the passed-in OrderAddress isn't already associated with this object
- if ($v !== null && $v->getOrder() === null) {
- $v->setOrder($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single OrderStatus object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return OrderStatus
- * @throws PropelException
- */
- public function getOrderStatus(PropelPDO $con = null)
- {
-
- if ($this->singleOrderStatus === null && !$this->isNew()) {
- $this->singleOrderStatus = OrderStatusQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleOrderStatus;
- }
-
- /**
- * Sets a single OrderStatus object as related to this object by a one-to-one relationship.
- *
- * @param OrderStatus $v OrderStatus
- * @return Order The current object (for fluent API support)
- * @throws PropelException
- */
- public function setOrderStatus(OrderStatus $v = null)
- {
- $this->singleOrderStatus = $v;
-
- // Make sure that that the passed-in OrderStatus isn't already associated with this object
- if ($v !== null && $v->getOrder() === null) {
- $v->setOrder($this);
- }
-
- return $this;
}
/**
@@ -2368,45 +2732,31 @@ abstract class BaseOrder extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCurrency) {
- $this->singleCurrency->clearAllReferences($deep);
+ if ($this->collCouponOrders) {
+ foreach ($this->collCouponOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
}
- if ($this->singleCustomer) {
- $this->singleCustomer->clearAllReferences($deep);
- }
- if ($this->singleOrderAddress) {
- $this->singleOrderAddress->clearAllReferences($deep);
- }
- if ($this->singleOrderAddress) {
- $this->singleOrderAddress->clearAllReferences($deep);
- }
- if ($this->singleOrderStatus) {
- $this->singleOrderStatus->clearAllReferences($deep);
+ if ($this->collOrderProducts) {
+ foreach ($this->collOrderProducts as $o) {
+ $o->clearAllReferences($deep);
+ }
}
} // if ($deep)
- if ($this->singleCurrency instanceof PropelCollection) {
- $this->singleCurrency->clearIterator();
+ if ($this->collCouponOrders instanceof PropelCollection) {
+ $this->collCouponOrders->clearIterator();
}
- $this->singleCurrency = null;
- if ($this->singleCustomer instanceof PropelCollection) {
- $this->singleCustomer->clearIterator();
+ $this->collCouponOrders = null;
+ if ($this->collOrderProducts instanceof PropelCollection) {
+ $this->collOrderProducts->clearIterator();
}
- $this->singleCustomer = null;
- if ($this->singleOrderAddress instanceof PropelCollection) {
- $this->singleOrderAddress->clearIterator();
- }
- $this->singleOrderAddress = null;
- if ($this->singleOrderAddress instanceof PropelCollection) {
- $this->singleOrderAddress->clearIterator();
- }
- $this->singleOrderAddress = null;
- if ($this->singleOrderStatus instanceof PropelCollection) {
- $this->singleOrderStatus->clearIterator();
- }
- $this->singleOrderStatus = null;
- $this->aCouponOrder = null;
- $this->aOrderProduct = null;
+ $this->collOrderProducts = null;
+ $this->aCurrency = null;
+ $this->aCustomer = null;
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ $this->aOrderStatus = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseOrderAddress.php b/core/lib/Thelia/Model/om/BaseOrderAddress.php
index c79a71029..b5115d9f0 100644
--- a/core/lib/Thelia/Model/om/BaseOrderAddress.php
+++ b/core/lib/Thelia/Model/om/BaseOrderAddress.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Order;
use Thelia\Model\OrderAddress;
@@ -132,14 +134,16 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Order
+ * @var PropelObjectCollection|Order[] Collection to store aggregation of Order objects.
*/
- protected $aOrder;
+ protected $collOrdersRelatedByAddressInvoice;
+ protected $collOrdersRelatedByAddressInvoicePartial;
/**
- * @var Order
+ * @var PropelObjectCollection|Order[] Collection to store aggregation of Order objects.
*/
- protected $aOrder;
+ protected $collOrdersRelatedByAddressDelivery;
+ protected $collOrdersRelatedByAddressDeliveryPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -155,6 +159,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $ordersRelatedByAddressInvoiceScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $ordersRelatedByAddressDeliveryScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -366,14 +382,6 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderAddressPeer::ID;
}
- if ($this->aOrder !== null && $this->aOrder->getAddressInvoice() !== $v) {
- $this->aOrder = null;
- }
-
- if ($this->aOrder !== null && $this->aOrder->getAddressDelivery() !== $v) {
- $this->aOrder = null;
- }
-
return $this;
} // setId()
@@ -732,12 +740,6 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aOrder !== null && $this->id !== $this->aOrder->getAddressInvoice()) {
- $this->aOrder = null;
- }
- if ($this->aOrder !== null && $this->id !== $this->aOrder->getAddressDelivery()) {
- $this->aOrder = null;
- }
} // ensureConsistency
/**
@@ -777,8 +779,10 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aOrder = null;
- $this->aOrder = null;
+ $this->collOrdersRelatedByAddressInvoice = null;
+
+ $this->collOrdersRelatedByAddressDelivery = null;
+
} // if (deep)
}
@@ -892,25 +896,6 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aOrder !== null) {
- if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
- $affectedRows += $this->aOrder->save($con);
- }
- $this->setOrder($this->aOrder);
- }
-
- if ($this->aOrder !== null) {
- if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
- $affectedRows += $this->aOrder->save($con);
- }
- $this->setOrder($this->aOrder);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -922,6 +907,42 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->ordersRelatedByAddressInvoiceScheduledForDeletion !== null) {
+ if (!$this->ordersRelatedByAddressInvoiceScheduledForDeletion->isEmpty()) {
+ foreach ($this->ordersRelatedByAddressInvoiceScheduledForDeletion as $orderRelatedByAddressInvoice) {
+ // need to save related object because we set the relation to null
+ $orderRelatedByAddressInvoice->save($con);
+ }
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrdersRelatedByAddressInvoice !== null) {
+ foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->ordersRelatedByAddressDeliveryScheduledForDeletion !== null) {
+ if (!$this->ordersRelatedByAddressDeliveryScheduledForDeletion->isEmpty()) {
+ foreach ($this->ordersRelatedByAddressDeliveryScheduledForDeletion as $orderRelatedByAddressDelivery) {
+ // need to save related object because we set the relation to null
+ $orderRelatedByAddressDelivery->save($con);
+ }
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrdersRelatedByAddressDelivery !== null) {
+ foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -1137,29 +1158,27 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aOrder !== null) {
- if (!$this->aOrder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
- }
- }
-
- if ($this->aOrder !== null) {
- if (!$this->aOrder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
- }
- }
-
-
if (($retval = OrderAddressPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collOrdersRelatedByAddressInvoice !== null) {
+ foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collOrdersRelatedByAddressDelivery !== null) {
+ foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1282,11 +1301,11 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
$keys[13] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aOrder) {
- $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collOrdersRelatedByAddressInvoice) {
+ $result['OrdersRelatedByAddressInvoice'] = $this->collOrdersRelatedByAddressInvoice->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aOrder) {
- $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collOrdersRelatedByAddressDelivery) {
+ $result['OrdersRelatedByAddressDelivery'] = $this->collOrdersRelatedByAddressDelivery->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1511,14 +1530,16 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getOrder();
- if ($relObj) {
- $copyObj->setOrder($relObj->copy($deepCopy));
+ foreach ($this->getOrdersRelatedByAddressInvoice() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderRelatedByAddressInvoice($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getOrder();
- if ($relObj) {
- $copyObj->setOrder($relObj->copy($deepCopy));
+ foreach ($this->getOrdersRelatedByAddressDelivery() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderRelatedByAddressDelivery($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1571,98 +1592,587 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a Order object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param Order $v
- * @return OrderAddress The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('OrderRelatedByAddressInvoice' == $relationName) {
+ $this->initOrdersRelatedByAddressInvoice();
+ }
+ if ('OrderRelatedByAddressDelivery' == $relationName) {
+ $this->initOrdersRelatedByAddressDelivery();
+ }
+ }
+
+ /**
+ * Clears out the collOrdersRelatedByAddressInvoice 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 addOrdersRelatedByAddressInvoice()
+ */
+ public function clearOrdersRelatedByAddressInvoice()
+ {
+ $this->collOrdersRelatedByAddressInvoice = null; // important to set this to null since that means it is uninitialized
+ $this->collOrdersRelatedByAddressInvoicePartial = null;
+ }
+
+ /**
+ * reset is the collOrdersRelatedByAddressInvoice collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialOrdersRelatedByAddressInvoice($v = true)
+ {
+ $this->collOrdersRelatedByAddressInvoicePartial = $v;
+ }
+
+ /**
+ * Initializes the collOrdersRelatedByAddressInvoice collection.
+ *
+ * By default this just sets the collOrdersRelatedByAddressInvoice collection to an empty array (like clearcollOrdersRelatedByAddressInvoice());
+ * 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 initOrdersRelatedByAddressInvoice($overrideExisting = true)
+ {
+ if (null !== $this->collOrdersRelatedByAddressInvoice && !$overrideExisting) {
+ return;
+ }
+ $this->collOrdersRelatedByAddressInvoice = new PropelObjectCollection();
+ $this->collOrdersRelatedByAddressInvoice->setModel('Order');
+ }
+
+ /**
+ * Gets an array of Order 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 OrderAddress 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|Order[] List of Order objects
* @throws PropelException
*/
- public function setOrder(Order $v = null)
+ public function getOrdersRelatedByAddressInvoice($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew();
+ if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) {
+ // return empty collection
+ $this->initOrdersRelatedByAddressInvoice();
+ } else {
+ $collOrdersRelatedByAddressInvoice = OrderQuery::create(null, $criteria)
+ ->filterByOrderAddressRelatedByAddressInvoice($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersRelatedByAddressInvoicePartial && count($collOrdersRelatedByAddressInvoice)) {
+ $this->initOrdersRelatedByAddressInvoice(false);
+
+ foreach($collOrdersRelatedByAddressInvoice as $obj) {
+ if (false == $this->collOrdersRelatedByAddressInvoice->contains($obj)) {
+ $this->collOrdersRelatedByAddressInvoice->append($obj);
+ }
+ }
+
+ $this->collOrdersRelatedByAddressInvoicePartial = true;
+ }
+
+ return $collOrdersRelatedByAddressInvoice;
+ }
+
+ if($partial && $this->collOrdersRelatedByAddressInvoice) {
+ foreach($this->collOrdersRelatedByAddressInvoice as $obj) {
+ if($obj->isNew()) {
+ $collOrdersRelatedByAddressInvoice[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrdersRelatedByAddressInvoice = $collOrdersRelatedByAddressInvoice;
+ $this->collOrdersRelatedByAddressInvoicePartial = false;
+ }
+ }
+
+ return $this->collOrdersRelatedByAddressInvoice;
+ }
+
+ /**
+ * Sets a collection of OrderRelatedByAddressInvoice 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 $ordersRelatedByAddressInvoice A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setOrdersRelatedByAddressInvoice(PropelCollection $ordersRelatedByAddressInvoice, PropelPDO $con = null)
+ {
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion = $this->getOrdersRelatedByAddressInvoice(new Criteria(), $con)->diff($ordersRelatedByAddressInvoice);
+
+ foreach ($this->ordersRelatedByAddressInvoiceScheduledForDeletion as $orderRelatedByAddressInvoiceRemoved) {
+ $orderRelatedByAddressInvoiceRemoved->setOrderAddressRelatedByAddressInvoice(null);
+ }
+
+ $this->collOrdersRelatedByAddressInvoice = null;
+ foreach ($ordersRelatedByAddressInvoice as $orderRelatedByAddressInvoice) {
+ $this->addOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice);
+ }
+
+ $this->collOrdersRelatedByAddressInvoice = $ordersRelatedByAddressInvoice;
+ $this->collOrdersRelatedByAddressInvoicePartial = false;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrdersRelatedByAddressInvoice(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew();
+ if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getOrdersRelatedByAddressInvoice());
+ }
+ $query = OrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderAddressRelatedByAddressInvoice($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getAddressInvoice());
+ return count($this->collOrdersRelatedByAddressInvoice);
}
+ }
- $this->aOrder = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setOrderAddress($this);
+ /**
+ * Method called to associate a Order object to this object
+ * through the Order foreign key attribute.
+ *
+ * @param Order $l Order
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function addOrderRelatedByAddressInvoice(Order $l)
+ {
+ if ($this->collOrdersRelatedByAddressInvoice === null) {
+ $this->initOrdersRelatedByAddressInvoice();
+ $this->collOrdersRelatedByAddressInvoicePartial = true;
+ }
+ if (!$this->collOrdersRelatedByAddressInvoice->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderRelatedByAddressInvoice($l);
}
-
return $this;
}
-
/**
- * Get the associated Order object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Order The associated Order object.
- * @throws PropelException
+ * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to add.
*/
- public function getOrder(PropelPDO $con = null)
+ protected function doAddOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice)
{
- if ($this->aOrder === null && ($this->id !== null)) {
- $this->aOrder = OrderQuery::create()
- ->filterByOrderAddress($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aOrder->setOrderAddress($this);
- }
-
- return $this->aOrder;
+ $this->collOrdersRelatedByAddressInvoice[]= $orderRelatedByAddressInvoice;
+ $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice($this);
}
/**
- * Declares an association between this object and a Order object.
+ * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to remove.
+ */
+ public function removeOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice)
+ {
+ if ($this->getOrdersRelatedByAddressInvoice()->contains($orderRelatedByAddressInvoice)) {
+ $this->collOrdersRelatedByAddressInvoice->remove($this->collOrdersRelatedByAddressInvoice->search($orderRelatedByAddressInvoice));
+ if (null === $this->ordersRelatedByAddressInvoiceScheduledForDeletion) {
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion = clone $this->collOrdersRelatedByAddressInvoice;
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion->clear();
+ }
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion[]= $orderRelatedByAddressInvoice;
+ $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage.
*
- * @param Order $v
- * @return OrderAddress The current object (for fluent API support)
+ * 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 OrderAddress.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersRelatedByAddressInvoiceJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('Currency', $join_behavior);
+
+ return $this->getOrdersRelatedByAddressInvoice($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressInvoice 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 OrderAddress.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersRelatedByAddressInvoiceJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('Customer', $join_behavior);
+
+ return $this->getOrdersRelatedByAddressInvoice($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressInvoice 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 OrderAddress.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersRelatedByAddressInvoiceJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderStatus', $join_behavior);
+
+ return $this->getOrdersRelatedByAddressInvoice($query, $con);
+ }
+
+ /**
+ * Clears out the collOrdersRelatedByAddressDelivery 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 addOrdersRelatedByAddressDelivery()
+ */
+ public function clearOrdersRelatedByAddressDelivery()
+ {
+ $this->collOrdersRelatedByAddressDelivery = null; // important to set this to null since that means it is uninitialized
+ $this->collOrdersRelatedByAddressDeliveryPartial = null;
+ }
+
+ /**
+ * reset is the collOrdersRelatedByAddressDelivery collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialOrdersRelatedByAddressDelivery($v = true)
+ {
+ $this->collOrdersRelatedByAddressDeliveryPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrdersRelatedByAddressDelivery collection.
+ *
+ * By default this just sets the collOrdersRelatedByAddressDelivery collection to an empty array (like clearcollOrdersRelatedByAddressDelivery());
+ * 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 initOrdersRelatedByAddressDelivery($overrideExisting = true)
+ {
+ if (null !== $this->collOrdersRelatedByAddressDelivery && !$overrideExisting) {
+ return;
+ }
+ $this->collOrdersRelatedByAddressDelivery = new PropelObjectCollection();
+ $this->collOrdersRelatedByAddressDelivery->setModel('Order');
+ }
+
+ /**
+ * Gets an array of Order 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 OrderAddress 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|Order[] List of Order objects
* @throws PropelException
*/
- public function setOrder(Order $v = null)
+ public function getOrdersRelatedByAddressDelivery($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew();
+ if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) {
+ // return empty collection
+ $this->initOrdersRelatedByAddressDelivery();
+ } else {
+ $collOrdersRelatedByAddressDelivery = OrderQuery::create(null, $criteria)
+ ->filterByOrderAddressRelatedByAddressDelivery($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersRelatedByAddressDeliveryPartial && count($collOrdersRelatedByAddressDelivery)) {
+ $this->initOrdersRelatedByAddressDelivery(false);
+
+ foreach($collOrdersRelatedByAddressDelivery as $obj) {
+ if (false == $this->collOrdersRelatedByAddressDelivery->contains($obj)) {
+ $this->collOrdersRelatedByAddressDelivery->append($obj);
+ }
+ }
+
+ $this->collOrdersRelatedByAddressDeliveryPartial = true;
+ }
+
+ return $collOrdersRelatedByAddressDelivery;
+ }
+
+ if($partial && $this->collOrdersRelatedByAddressDelivery) {
+ foreach($this->collOrdersRelatedByAddressDelivery as $obj) {
+ if($obj->isNew()) {
+ $collOrdersRelatedByAddressDelivery[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrdersRelatedByAddressDelivery = $collOrdersRelatedByAddressDelivery;
+ $this->collOrdersRelatedByAddressDeliveryPartial = false;
+ }
+ }
+
+ return $this->collOrdersRelatedByAddressDelivery;
+ }
+
+ /**
+ * Sets a collection of OrderRelatedByAddressDelivery 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 $ordersRelatedByAddressDelivery A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setOrdersRelatedByAddressDelivery(PropelCollection $ordersRelatedByAddressDelivery, PropelPDO $con = null)
+ {
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion = $this->getOrdersRelatedByAddressDelivery(new Criteria(), $con)->diff($ordersRelatedByAddressDelivery);
+
+ foreach ($this->ordersRelatedByAddressDeliveryScheduledForDeletion as $orderRelatedByAddressDeliveryRemoved) {
+ $orderRelatedByAddressDeliveryRemoved->setOrderAddressRelatedByAddressDelivery(null);
+ }
+
+ $this->collOrdersRelatedByAddressDelivery = null;
+ foreach ($ordersRelatedByAddressDelivery as $orderRelatedByAddressDelivery) {
+ $this->addOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery);
+ }
+
+ $this->collOrdersRelatedByAddressDelivery = $ordersRelatedByAddressDelivery;
+ $this->collOrdersRelatedByAddressDeliveryPartial = false;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrdersRelatedByAddressDelivery(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew();
+ if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getOrdersRelatedByAddressDelivery());
+ }
+ $query = OrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderAddressRelatedByAddressDelivery($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getAddressDelivery());
+ return count($this->collOrdersRelatedByAddressDelivery);
}
+ }
- $this->aOrder = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setOrderAddress($this);
+ /**
+ * Method called to associate a Order object to this object
+ * through the Order foreign key attribute.
+ *
+ * @param Order $l Order
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function addOrderRelatedByAddressDelivery(Order $l)
+ {
+ if ($this->collOrdersRelatedByAddressDelivery === null) {
+ $this->initOrdersRelatedByAddressDelivery();
+ $this->collOrdersRelatedByAddressDeliveryPartial = true;
+ }
+ if (!$this->collOrdersRelatedByAddressDelivery->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderRelatedByAddressDelivery($l);
}
-
return $this;
}
+ /**
+ * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to add.
+ */
+ protected function doAddOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery)
+ {
+ $this->collOrdersRelatedByAddressDelivery[]= $orderRelatedByAddressDelivery;
+ $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery($this);
+ }
/**
- * Get the associated Order object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Order The associated Order object.
- * @throws PropelException
+ * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove.
*/
- public function getOrder(PropelPDO $con = null)
+ public function removeOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery)
{
- if ($this->aOrder === null && ($this->id !== null)) {
- $this->aOrder = OrderQuery::create()
- ->filterByOrderAddress($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aOrder->setOrderAddress($this);
+ if ($this->getOrdersRelatedByAddressDelivery()->contains($orderRelatedByAddressDelivery)) {
+ $this->collOrdersRelatedByAddressDelivery->remove($this->collOrdersRelatedByAddressDelivery->search($orderRelatedByAddressDelivery));
+ if (null === $this->ordersRelatedByAddressDeliveryScheduledForDeletion) {
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion = clone $this->collOrdersRelatedByAddressDelivery;
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion->clear();
+ }
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion[]= $orderRelatedByAddressDelivery;
+ $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery(null);
}
+ }
- return $this->aOrder;
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressDelivery 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 OrderAddress.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersRelatedByAddressDeliveryJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('Currency', $join_behavior);
+
+ return $this->getOrdersRelatedByAddressDelivery($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressDelivery 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 OrderAddress.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersRelatedByAddressDeliveryJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('Customer', $join_behavior);
+
+ return $this->getOrdersRelatedByAddressDelivery($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressDelivery 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 OrderAddress.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersRelatedByAddressDeliveryJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderStatus', $join_behavior);
+
+ return $this->getOrdersRelatedByAddressDelivery($query, $con);
}
/**
@@ -1704,10 +2214,26 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collOrdersRelatedByAddressInvoice) {
+ foreach ($this->collOrdersRelatedByAddressInvoice as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrdersRelatedByAddressDelivery) {
+ foreach ($this->collOrdersRelatedByAddressDelivery as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aOrder = null;
- $this->aOrder = null;
+ if ($this->collOrdersRelatedByAddressInvoice instanceof PropelCollection) {
+ $this->collOrdersRelatedByAddressInvoice->clearIterator();
+ }
+ $this->collOrdersRelatedByAddressInvoice = null;
+ if ($this->collOrdersRelatedByAddressDelivery instanceof PropelCollection) {
+ $this->collOrdersRelatedByAddressDelivery->clearIterator();
+ }
+ $this->collOrdersRelatedByAddressDelivery = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php b/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php
index 477486380..eab7445dd 100644
--- a/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php
+++ b/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php
@@ -25,7 +25,7 @@ abstract class BaseOrderAddressPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'order_address';
@@ -428,6 +428,12 @@ abstract class BaseOrderAddressPeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in OrderPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderPeer::clearInstancePool();
+ // Invalidate objects in OrderPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderPeer::clearInstancePool();
}
/**
@@ -524,587 +530,6 @@ abstract class BaseOrderAddressPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderAddressPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderAddressPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(OrderAddressPeer::ID, OrderPeer::ADDRESS_INVOICE, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderAddressPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderAddressPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(OrderAddressPeer::ID, OrderPeer::ADDRESS_DELIVERY, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of OrderAddress objects pre-filled with their Order objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderAddress objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
- }
-
- OrderAddressPeer::addSelectColumns($criteria);
- $startcol = OrderAddressPeer::NUM_HYDRATE_COLUMNS;
- OrderPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(OrderAddressPeer::ID, OrderPeer::ADDRESS_INVOICE, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderAddressPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = OrderAddressPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderAddressPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (OrderAddress) to $obj2 (Order)
- // one to one relationship
- $obj1->setOrder($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of OrderAddress objects pre-filled with their Order objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderAddress objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
- }
-
- OrderAddressPeer::addSelectColumns($criteria);
- $startcol = OrderAddressPeer::NUM_HYDRATE_COLUMNS;
- OrderPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(OrderAddressPeer::ID, OrderPeer::ADDRESS_DELIVERY, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderAddressPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = OrderAddressPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderAddressPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (OrderAddress) to $obj2 (Order)
- // one to one relationship
- $obj1->setOrder($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderAddressPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderAddressPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(OrderAddressPeer::ID, OrderPeer::ADDRESS_INVOICE, $join_behavior);
-
- $criteria->addJoin(OrderAddressPeer::ID, OrderPeer::ADDRESS_DELIVERY, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of OrderAddress objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderAddress objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
- }
-
- OrderAddressPeer::addSelectColumns($criteria);
- $startcol2 = OrderAddressPeer::NUM_HYDRATE_COLUMNS;
-
- OrderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS;
-
- OrderPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + OrderPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(OrderAddressPeer::ID, OrderPeer::ADDRESS_INVOICE, $join_behavior);
-
- $criteria->addJoin(OrderAddressPeer::ID, OrderPeer::ADDRESS_DELIVERY, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderAddressPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = OrderAddressPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderAddressPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Order rows
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (OrderAddress) to the collection in $obj2 (Order)
- $obj1->setOrder($obj2);
- } // if joined row not null
-
- // Add objects for joined Order rows
-
- $key3 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = OrderPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- OrderPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (OrderAddress) to the collection in $obj3 (Order)
- $obj1->setOrder($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderAddressPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderAddressPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderAddressPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderAddressPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of OrderAddress objects pre-filled with all related objects except Order.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderAddress objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
- }
-
- OrderAddressPeer::addSelectColumns($criteria);
- $startcol2 = OrderAddressPeer::NUM_HYDRATE_COLUMNS;
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderAddressPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = OrderAddressPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderAddressPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of OrderAddress objects pre-filled with all related objects except Order.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderAddress objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
- }
-
- OrderAddressPeer::addSelectColumns($criteria);
- $startcol2 = OrderAddressPeer::NUM_HYDRATE_COLUMNS;
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderAddressPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = OrderAddressPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderAddressPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php
index 1da523b4c..848b0a8b4 100644
--- a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php
+++ b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php
@@ -56,13 +56,13 @@ use Thelia\Model\OrderAddressQuery;
* @method OrderAddressQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method OrderAddressQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method OrderAddressQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation
- * @method OrderAddressQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
- * @method OrderAddressQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
+ * @method OrderAddressQuery leftJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByAddressInvoice relation
+ * @method OrderAddressQuery rightJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByAddressInvoice relation
+ * @method OrderAddressQuery innerJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByAddressInvoice relation
*
- * @method OrderAddressQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation
- * @method OrderAddressQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
- * @method OrderAddressQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
+ * @method OrderAddressQuery leftJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByAddressDelivery relation
+ * @method OrderAddressQuery rightJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByAddressDelivery relation
+ * @method OrderAddressQuery innerJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByAddressDelivery relation
*
* @method OrderAddress findOne(PropelPDO $con = null) Return the first OrderAddress matching the query
* @method OrderAddress findOneOrCreate(PropelPDO $con = null) Return the first OrderAddress matching the query, or a new OrderAddress object populated from the query conditions when no match is found
@@ -108,7 +108,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\OrderAddress', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\OrderAddress', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -284,10 +284,6 @@ abstract class BaseOrderAddressQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByOrder()
- *
- * @see filterByOrder()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -737,41 +733,39 @@ abstract class BaseOrderAddressQuery extends ModelCriteria
/**
* Filter the query by a related Order object
*
- * @param Order|PropelObjectCollection $order The related object(s) to use as filter
+ * @param Order|PropelObjectCollection $order the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderAddressQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByOrder($order, $comparison = null)
+ public function filterByOrderRelatedByAddressInvoice($order, $comparison = null)
{
if ($order instanceof Order) {
return $this
->addUsingAlias(OrderAddressPeer::ID, $order->getAddressInvoice(), $comparison);
} elseif ($order instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(OrderAddressPeer::ID, $order->toKeyValue('PrimaryKey', 'AddressInvoice'), $comparison);
+ ->useOrderRelatedByAddressInvoiceQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
} else {
- throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
+ throw new PropelException('filterByOrderRelatedByAddressInvoice() only accepts arguments of type Order or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the Order relation
+ * Adds a JOIN clause to the query using the OrderRelatedByAddressInvoice relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return OrderAddressQuery The current query, for fluid interface
*/
- public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinOrderRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Order');
+ $relationMap = $tableMap->getRelation('OrderRelatedByAddressInvoice');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -786,14 +780,14 @@ abstract class BaseOrderAddressQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'Order');
+ $this->addJoinObject($join, 'OrderRelatedByAddressInvoice');
}
return $this;
}
/**
- * Use the Order relation Order object
+ * Use the OrderRelatedByAddressInvoice relation Order object
*
* @see useQuery()
*
@@ -803,51 +797,49 @@ abstract class BaseOrderAddressQuery extends ModelCriteria
*
* @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
*/
- public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useOrderRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
- ->joinOrder($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ ->joinOrderRelatedByAddressInvoice($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressInvoice', '\Thelia\Model\OrderQuery');
}
/**
* Filter the query by a related Order object
*
- * @param Order|PropelObjectCollection $order The related object(s) to use as filter
+ * @param Order|PropelObjectCollection $order the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderAddressQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByOrder($order, $comparison = null)
+ public function filterByOrderRelatedByAddressDelivery($order, $comparison = null)
{
if ($order instanceof Order) {
return $this
->addUsingAlias(OrderAddressPeer::ID, $order->getAddressDelivery(), $comparison);
} elseif ($order instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(OrderAddressPeer::ID, $order->toKeyValue('PrimaryKey', 'AddressDelivery'), $comparison);
+ ->useOrderRelatedByAddressDeliveryQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
} else {
- throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
+ throw new PropelException('filterByOrderRelatedByAddressDelivery() only accepts arguments of type Order or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the Order relation
+ * Adds a JOIN clause to the query using the OrderRelatedByAddressDelivery relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return OrderAddressQuery The current query, for fluid interface
*/
- public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinOrderRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Order');
+ $relationMap = $tableMap->getRelation('OrderRelatedByAddressDelivery');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -862,14 +854,14 @@ abstract class BaseOrderAddressQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'Order');
+ $this->addJoinObject($join, 'OrderRelatedByAddressDelivery');
}
return $this;
}
/**
- * Use the Order relation Order object
+ * Use the OrderRelatedByAddressDelivery relation Order object
*
* @see useQuery()
*
@@ -879,11 +871,11 @@ abstract class BaseOrderAddressQuery extends ModelCriteria
*
* @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
*/
- public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useOrderRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
- ->joinOrder($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ ->joinOrderRelatedByAddressDelivery($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressDelivery', '\Thelia\Model\OrderQuery');
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseOrderFeature.php b/core/lib/Thelia/Model/om/BaseOrderFeature.php
index 04c719847..ffbc3aac4 100644
--- a/core/lib/Thelia/Model/om/BaseOrderFeature.php
+++ b/core/lib/Thelia/Model/om/BaseOrderFeature.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\OrderFeature;
use Thelia\Model\OrderFeaturePeer;
@@ -86,9 +84,9 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var OrderProduct one-to-one related OrderProduct object
+ * @var OrderProduct
*/
- protected $singleOrderProduct;
+ protected $aOrderProduct;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -104,12 +102,6 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $orderProductsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -262,6 +254,10 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderFeaturePeer::ORDER_PRODUCT_ID;
}
+ if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) {
+ $this->aOrderProduct = null;
+ }
+
return $this;
} // setOrderProductId()
@@ -423,6 +419,9 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) {
+ $this->aOrderProduct = null;
+ }
} // ensureConsistency
/**
@@ -462,8 +461,7 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleOrderProduct = null;
-
+ $this->aOrderProduct = null;
} // if (deep)
}
@@ -577,6 +575,18 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrderProduct !== null) {
+ if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) {
+ $affectedRows += $this->aOrderProduct->save($con);
+ }
+ $this->setOrderProduct($this->aOrderProduct);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -588,21 +598,6 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->orderProductsScheduledForDeletion !== null) {
- if (!$this->orderProductsScheduledForDeletion->isEmpty()) {
- OrderProductQuery::create()
- ->filterByPrimaryKeys($this->orderProductsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->orderProductsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleOrderProduct !== null) {
- if (!$this->singleOrderProduct->isDeleted()) {
- $affectedRows += $this->singleOrderProduct->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -770,17 +765,23 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrderProduct !== null) {
+ if (!$this->aOrderProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aOrderProduct->getValidationFailures());
+ }
+ }
+
+
if (($retval = OrderFeaturePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleOrderProduct !== null) {
- if (!$this->singleOrderProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleOrderProduct->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -871,8 +872,8 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
$keys[5] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleOrderProduct) {
- $result['OrderProduct'] = $this->singleOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aOrderProduct) {
+ $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1049,11 +1050,6 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getOrderProduct();
- if ($relObj) {
- $copyObj->setOrderProduct($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1104,55 +1100,57 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a OrderProduct object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single OrderProduct object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return OrderProduct
- * @throws PropelException
- */
- public function getOrderProduct(PropelPDO $con = null)
- {
-
- if ($this->singleOrderProduct === null && !$this->isNew()) {
- $this->singleOrderProduct = OrderProductQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleOrderProduct;
- }
-
- /**
- * Sets a single OrderProduct object as related to this object by a one-to-one relationship.
- *
- * @param OrderProduct $v OrderProduct
+ * @param OrderProduct $v
* @return OrderFeature The current object (for fluent API support)
* @throws PropelException
*/
public function setOrderProduct(OrderProduct $v = null)
{
- $this->singleOrderProduct = $v;
-
- // Make sure that that the passed-in OrderProduct isn't already associated with this object
- if ($v !== null && $v->getOrderFeature() === null) {
- $v->setOrderFeature($this);
+ if ($v === null) {
+ $this->setOrderProductId(NULL);
+ } else {
+ $this->setOrderProductId($v->getId());
}
+ $this->aOrderProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the OrderProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderFeature($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated OrderProduct object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return OrderProduct The associated OrderProduct object.
+ * @throws PropelException
+ */
+ public function getOrderProduct(PropelPDO $con = null)
+ {
+ if ($this->aOrderProduct === null && ($this->order_product_id !== null)) {
+ $this->aOrderProduct = OrderProductQuery::create()->findPk($this->order_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->aOrderProduct->addOrderFeatures($this);
+ */
+ }
+
+ return $this->aOrderProduct;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1184,15 +1182,9 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleOrderProduct) {
- $this->singleOrderProduct->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleOrderProduct instanceof PropelCollection) {
- $this->singleOrderProduct->clearIterator();
- }
- $this->singleOrderProduct = null;
+ $this->aOrderProduct = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php b/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php
index ffc36e0e6..08c6a6e47 100644
--- a/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php
+++ b/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php
@@ -25,7 +25,7 @@ abstract class BaseOrderFeaturePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'order_feature';
@@ -388,9 +388,6 @@ abstract class BaseOrderFeaturePeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in OrderProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- OrderProductPeer::clearInstancePool();
}
/**
@@ -487,6 +484,244 @@ abstract class BaseOrderFeaturePeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related OrderProduct table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinOrderProduct(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderFeaturePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderFeaturePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderFeaturePeer::ORDER_PRODUCT_ID, OrderProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of OrderFeature objects pre-filled with their OrderProduct objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of OrderFeature objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinOrderProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME);
+ }
+
+ OrderFeaturePeer::addSelectColumns($criteria);
+ $startcol = OrderFeaturePeer::NUM_HYDRATE_COLUMNS;
+ OrderProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(OrderFeaturePeer::ORDER_PRODUCT_ID, OrderProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderFeaturePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = OrderFeaturePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderFeaturePeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = OrderProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ OrderProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (OrderFeature) to $obj2 (OrderProduct)
+ $obj2->addOrderFeature($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderFeaturePeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderFeaturePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderFeaturePeer::ORDER_PRODUCT_ID, OrderProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of OrderFeature objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of OrderFeature objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME);
+ }
+
+ OrderFeaturePeer::addSelectColumns($criteria);
+ $startcol2 = OrderFeaturePeer::NUM_HYDRATE_COLUMNS;
+
+ OrderProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + OrderProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderFeaturePeer::ORDER_PRODUCT_ID, OrderProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderFeaturePeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = OrderFeaturePeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderFeaturePeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined OrderProduct rows
+
+ $key2 = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = OrderProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ OrderProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (OrderFeature) to the collection in $obj2 (OrderProduct)
+ $obj2->addOrderFeature($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -620,7 +855,6 @@ abstract class BaseOrderFeaturePeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += OrderFeaturePeer::doOnDeleteCascade(new Criteria(OrderFeaturePeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(OrderFeaturePeer::TABLE_NAME, $con, OrderFeaturePeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -654,14 +888,24 @@ abstract class BaseOrderFeaturePeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ OrderFeaturePeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof OrderFeature) { // it's a model object
+ // invalidate the cache for this single object
+ OrderFeaturePeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME);
$criteria->add(OrderFeaturePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ OrderFeaturePeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -674,23 +918,6 @@ abstract class BaseOrderFeaturePeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += OrderFeaturePeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- OrderFeaturePeer::clearInstancePool();
- } elseif ($values instanceof OrderFeature) { // it's a model object
- OrderFeaturePeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- OrderFeaturePeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
OrderFeaturePeer::clearRelatedInstancePool();
$con->commit();
@@ -702,39 +929,6 @@ abstract class BaseOrderFeaturePeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = OrderFeaturePeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related OrderProduct objects
- $criteria = new Criteria(OrderProductPeer::DATABASE_NAME);
-
- $criteria->add(OrderProductPeer::ID, $obj->getOrderProductId());
- $affectedRows += OrderProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given OrderFeature object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php
index dbed24020..6e1cb964c 100644
--- a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php
+++ b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php
@@ -72,7 +72,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\OrderFeature', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\OrderFeature', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -275,6 +275,8 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria
* $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12
*
*
+ * @see filterByOrderProduct()
+ *
* @param mixed $orderProductId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -453,7 +455,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria
/**
* Filter the query by a related OrderProduct object
*
- * @param OrderProduct|PropelObjectCollection $orderProduct the related object to use as filter
+ * @param OrderProduct|PropelObjectCollection $orderProduct The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderFeatureQuery The current query, for fluid interface
@@ -465,10 +467,12 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria
return $this
->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison);
} elseif ($orderProduct instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useOrderProductQuery()
- ->filterByPrimaryKeys($orderProduct->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByOrderProduct() only accepts arguments of type OrderProduct or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseOrderPeer.php b/core/lib/Thelia/Model/om/BaseOrderPeer.php
index 3f24569f4..1926b7931 100644
--- a/core/lib/Thelia/Model/om/BaseOrderPeer.php
+++ b/core/lib/Thelia/Model/om/BaseOrderPeer.php
@@ -30,7 +30,7 @@ abstract class BaseOrderPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'order';
@@ -453,21 +453,12 @@ abstract class BaseOrderPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CurrencyPeer instance pool,
+ // Invalidate objects in CouponOrderPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CurrencyPeer::clearInstancePool();
- // Invalidate objects in CustomerPeer instance pool,
+ CouponOrderPeer::clearInstancePool();
+ // Invalidate objects in OrderProductPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CustomerPeer::clearInstancePool();
- // Invalidate objects in OrderAddressPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- OrderAddressPeer::clearInstancePool();
- // Invalidate objects in OrderAddressPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- OrderAddressPeer::clearInstancePool();
- // Invalidate objects in OrderStatusPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- OrderStatusPeer::clearInstancePool();
+ OrderProductPeer::clearInstancePool();
}
/**
@@ -566,7 +557,7 @@ abstract class BaseOrderPeer
/**
- * Returns the number of rows matching criteria, joining the related CouponOrder table
+ * Returns the number of rows matching criteria, joining the related Currency table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -574,7 +565,7 @@ abstract class BaseOrderPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinCouponOrder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinCurrency(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;
@@ -601,7 +592,7 @@ abstract class BaseOrderPeer
$con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(OrderPeer::ID, CouponOrderPeer::ORDER_ID, $join_behavior);
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -617,7 +608,7 @@ abstract class BaseOrderPeer
/**
- * Returns the number of rows matching criteria, joining the related OrderProduct table
+ * Returns the number of rows matching criteria, joining the related Customer table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -625,7 +616,7 @@ abstract class BaseOrderPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinOrderProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinCustomer(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;
@@ -652,7 +643,7 @@ abstract class BaseOrderPeer
$con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(OrderPeer::ID, OrderProductPeer::ORDER_ID, $join_behavior);
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -668,7 +659,160 @@ abstract class BaseOrderPeer
/**
- * Selects a collection of Order objects pre-filled with their CouponOrder objects.
+ * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressInvoice table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinOrderAddressRelatedByAddressInvoice(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressDelivery table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinOrderAddressRelatedByAddressDelivery(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related OrderStatus table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinOrderStatus(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Order objects pre-filled with their Currency objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -676,7 +820,7 @@ abstract class BaseOrderPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinCouponOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinCurrency(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -687,9 +831,9 @@ abstract class BaseOrderPeer
OrderPeer::addSelectColumns($criteria);
$startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
- CouponOrderPeer::addSelectColumns($criteria);
+ CurrencyPeer::addSelectColumns($criteria);
- $criteria->addJoin(OrderPeer::ID, CouponOrderPeer::ORDER_ID, $join_behavior);
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -709,21 +853,20 @@ abstract class BaseOrderPeer
OrderPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = CouponOrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = CouponOrderPeer::getInstanceFromPool($key2);
+ $obj2 = CurrencyPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = CouponOrderPeer::getOMClass();
+ $cls = CurrencyPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- CouponOrderPeer::addInstanceToPool($obj2, $key2);
+ CurrencyPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (Order) to $obj2 (CouponOrder)
- // one to one relationship
- $obj1->setCouponOrder($obj2);
+ // Add the $obj1 (Order) to $obj2 (Currency)
+ $obj2->addOrder($obj1);
} // if joined row was not null
@@ -736,7 +879,7 @@ abstract class BaseOrderPeer
/**
- * Selects a collection of Order objects pre-filled with their OrderProduct objects.
+ * Selects a collection of Order objects pre-filled with their Customer objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -744,7 +887,7 @@ abstract class BaseOrderPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinOrderProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -755,9 +898,9 @@ abstract class BaseOrderPeer
OrderPeer::addSelectColumns($criteria);
$startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
- OrderProductPeer::addSelectColumns($criteria);
+ CustomerPeer::addSelectColumns($criteria);
- $criteria->addJoin(OrderPeer::ID, OrderProductPeer::ORDER_ID, $join_behavior);
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -777,21 +920,221 @@ abstract class BaseOrderPeer
OrderPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = OrderProductPeer::getInstanceFromPool($key2);
+ $obj2 = CustomerPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = OrderProductPeer::getOMClass();
+ $cls = CustomerPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- OrderProductPeer::addInstanceToPool($obj2, $key2);
+ CustomerPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (Order) to $obj2 (OrderProduct)
- // one to one relationship
- $obj1->setOrderProduct($obj2);
+ // Add the $obj1 (Order) to $obj2 (Customer)
+ $obj2->addOrder($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Order objects pre-filled with their OrderAddress objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Order objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinOrderAddressRelatedByAddressInvoice(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+ }
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
+ OrderAddressPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = OrderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = OrderAddressPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ OrderAddressPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Order) to $obj2 (OrderAddress)
+ $obj2->addOrderRelatedByAddressInvoice($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Order objects pre-filled with their OrderAddress objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Order objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinOrderAddressRelatedByAddressDelivery(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+ }
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
+ OrderAddressPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = OrderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = OrderAddressPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ OrderAddressPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Order) to $obj2 (OrderAddress)
+ $obj2->addOrderRelatedByAddressDelivery($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Order objects pre-filled with their OrderStatus objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Order objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinOrderStatus(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+ }
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
+ OrderStatusPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = OrderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = OrderStatusPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderStatusPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ OrderStatusPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Order) to $obj2 (OrderStatus)
+ $obj2->addOrder($obj1);
} // if joined row was not null
@@ -839,9 +1182,15 @@ abstract class BaseOrderPeer
$con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(OrderPeer::ID, CouponOrderPeer::ORDER_ID, $join_behavior);
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
- $criteria->addJoin(OrderPeer::ID, OrderProductPeer::ORDER_ID, $join_behavior);
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -877,15 +1226,30 @@ abstract class BaseOrderPeer
OrderPeer::addSelectColumns($criteria);
$startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
- CouponOrderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CouponOrderPeer::NUM_HYDRATE_COLUMNS;
+ CurrencyPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
- OrderProductPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + OrderProductPeer::NUM_HYDRATE_COLUMNS;
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
- $criteria->addJoin(OrderPeer::ID, CouponOrderPeer::ORDER_ID, $join_behavior);
+ OrderAddressPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
- $criteria->addJoin(OrderPeer::ID, OrderProductPeer::ORDER_ID, $join_behavior);
+ OrderAddressPeer::addSelectColumns($criteria);
+ $startcol6 = $startcol5 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderStatusPeer::addSelectColumns($criteria);
+ $startcol7 = $startcol6 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -904,40 +1268,94 @@ abstract class BaseOrderPeer
OrderPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined CouponOrder rows
+ // Add objects for joined Currency rows
- $key2 = CouponOrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = CouponOrderPeer::getInstanceFromPool($key2);
+ $obj2 = CurrencyPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = CouponOrderPeer::getOMClass();
+ $cls = CurrencyPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- CouponOrderPeer::addInstanceToPool($obj2, $key2);
+ CurrencyPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (Order) to the collection in $obj2 (CouponOrder)
- $obj1->setCouponOrder($obj2);
+ // Add the $obj1 (Order) to the collection in $obj2 (Currency)
+ $obj2->addOrder($obj1);
} // if joined row not null
- // Add objects for joined OrderProduct rows
+ // Add objects for joined Customer rows
- $key3 = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
if ($key3 !== null) {
- $obj3 = OrderProductPeer::getInstanceFromPool($key3);
+ $obj3 = CustomerPeer::getInstanceFromPool($key3);
if (!$obj3) {
- $cls = OrderProductPeer::getOMClass();
+ $cls = CustomerPeer::getOMClass();
$obj3 = new $cls();
$obj3->hydrate($row, $startcol3);
- OrderProductPeer::addInstanceToPool($obj3, $key3);
+ CustomerPeer::addInstanceToPool($obj3, $key3);
} // if obj3 loaded
- // Add the $obj1 (Order) to the collection in $obj3 (OrderProduct)
- $obj1->setOrderProduct($obj3);
+ // Add the $obj1 (Order) to the collection in $obj3 (Customer)
+ $obj3->addOrder($obj1);
+ } // if joined row not null
+
+ // Add objects for joined OrderAddress rows
+
+ $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = OrderAddressPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ OrderAddressPeer::addInstanceToPool($obj4, $key4);
+ } // if obj4 loaded
+
+ // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress)
+ $obj4->addOrderRelatedByAddressInvoice($obj1);
+ } // if joined row not null
+
+ // Add objects for joined OrderAddress rows
+
+ $key5 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol5);
+ if ($key5 !== null) {
+ $obj5 = OrderAddressPeer::getInstanceFromPool($key5);
+ if (!$obj5) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj5 = new $cls();
+ $obj5->hydrate($row, $startcol5);
+ OrderAddressPeer::addInstanceToPool($obj5, $key5);
+ } // if obj5 loaded
+
+ // Add the $obj1 (Order) to the collection in $obj5 (OrderAddress)
+ $obj5->addOrderRelatedByAddressDelivery($obj1);
+ } // if joined row not null
+
+ // Add objects for joined OrderStatus rows
+
+ $key6 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol6);
+ if ($key6 !== null) {
+ $obj6 = OrderStatusPeer::getInstanceFromPool($key6);
+ if (!$obj6) {
+
+ $cls = OrderStatusPeer::getOMClass();
+
+ $obj6 = new $cls();
+ $obj6->hydrate($row, $startcol6);
+ OrderStatusPeer::addInstanceToPool($obj6, $key6);
+ } // if obj6 loaded
+
+ // Add the $obj1 (Order) to the collection in $obj6 (OrderStatus)
+ $obj6->addOrder($obj1);
} // if joined row not null
$results[] = $obj1;
@@ -949,7 +1367,7 @@ abstract class BaseOrderPeer
/**
- * Returns the number of rows matching criteria, joining the related CouponOrder table
+ * Returns the number of rows matching criteria, joining the related Currency table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -957,7 +1375,7 @@ abstract class BaseOrderPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinAllExceptCouponOrder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinAllExceptCurrency(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;
@@ -984,7 +1402,13 @@ abstract class BaseOrderPeer
$con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(OrderPeer::ID, OrderProductPeer::ORDER_ID, $join_behavior);
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -1000,7 +1424,7 @@ abstract class BaseOrderPeer
/**
- * Returns the number of rows matching criteria, joining the related OrderProduct table
+ * Returns the number of rows matching criteria, joining the related Customer table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -1008,7 +1432,7 @@ abstract class BaseOrderPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinAllExceptOrderProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinAllExceptCustomer(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;
@@ -1035,7 +1459,13 @@ abstract class BaseOrderPeer
$con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(OrderPeer::ID, CouponOrderPeer::ORDER_ID, $join_behavior);
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -1051,7 +1481,174 @@ abstract class BaseOrderPeer
/**
- * Selects a collection of Order objects pre-filled with all related objects except CouponOrder.
+ * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressInvoice table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptOrderAddressRelatedByAddressInvoice(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressDelivery table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptOrderAddressRelatedByAddressDelivery(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related OrderStatus table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptOrderStatus(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Order objects pre-filled with all related objects except Currency.
*
* @param Criteria $criteria
* @param PropelPDO $con
@@ -1060,7 +1657,7 @@ abstract class BaseOrderPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinAllExceptCouponOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinAllExceptCurrency(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -1074,10 +1671,25 @@ abstract class BaseOrderPeer
OrderPeer::addSelectColumns($criteria);
$startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
- OrderProductPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + OrderProductPeer::NUM_HYDRATE_COLUMNS;
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS;
- $criteria->addJoin(OrderPeer::ID, OrderProductPeer::ORDER_ID, $join_behavior);
+ OrderAddressPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderAddressPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderStatusPeer::addSelectColumns($criteria);
+ $startcol6 = $startcol5 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
@@ -1097,22 +1709,79 @@ abstract class BaseOrderPeer
OrderPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined OrderProduct rows
+ // Add objects for joined Customer rows
- $key2 = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = OrderProductPeer::getInstanceFromPool($key2);
+ $obj2 = CustomerPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = OrderProductPeer::getOMClass();
+ $cls = CustomerPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- OrderProductPeer::addInstanceToPool($obj2, $key2);
+ CustomerPeer::addInstanceToPool($obj2, $key2);
} // if $obj2 already loaded
- // Add the $obj1 (Order) to the collection in $obj2 (OrderProduct)
- $obj1->setOrderProduct($obj2);
+ // Add the $obj1 (Order) to the collection in $obj2 (Customer)
+ $obj2->addOrder($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderAddress rows
+
+ $key3 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = OrderAddressPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ OrderAddressPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj3 (OrderAddress)
+ $obj3->addOrderRelatedByAddressInvoice($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderAddress rows
+
+ $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = OrderAddressPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ OrderAddressPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress)
+ $obj4->addOrderRelatedByAddressDelivery($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderStatus rows
+
+ $key5 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol5);
+ if ($key5 !== null) {
+ $obj5 = OrderStatusPeer::getInstanceFromPool($key5);
+ if (!$obj5) {
+
+ $cls = OrderStatusPeer::getOMClass();
+
+ $obj5 = new $cls();
+ $obj5->hydrate($row, $startcol5);
+ OrderStatusPeer::addInstanceToPool($obj5, $key5);
+ } // if $obj5 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj5 (OrderStatus)
+ $obj5->addOrder($obj1);
} // if joined row is not null
@@ -1125,7 +1794,7 @@ abstract class BaseOrderPeer
/**
- * Selects a collection of Order objects pre-filled with all related objects except OrderProduct.
+ * Selects a collection of Order objects pre-filled with all related objects except Customer.
*
* @param Criteria $criteria
* @param PropelPDO $con
@@ -1134,7 +1803,7 @@ abstract class BaseOrderPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinAllExceptOrderProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinAllExceptCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -1148,10 +1817,25 @@ abstract class BaseOrderPeer
OrderPeer::addSelectColumns($criteria);
$startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
- CouponOrderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CouponOrderPeer::NUM_HYDRATE_COLUMNS;
+ CurrencyPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
- $criteria->addJoin(OrderPeer::ID, CouponOrderPeer::ORDER_ID, $join_behavior);
+ OrderAddressPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderAddressPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderStatusPeer::addSelectColumns($criteria);
+ $startcol6 = $startcol5 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
@@ -1171,22 +1855,469 @@ abstract class BaseOrderPeer
OrderPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined CouponOrder rows
+ // Add objects for joined Currency rows
- $key2 = CouponOrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = CouponOrderPeer::getInstanceFromPool($key2);
+ $obj2 = CurrencyPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = CouponOrderPeer::getOMClass();
+ $cls = CurrencyPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- CouponOrderPeer::addInstanceToPool($obj2, $key2);
+ CurrencyPeer::addInstanceToPool($obj2, $key2);
} // if $obj2 already loaded
- // Add the $obj1 (Order) to the collection in $obj2 (CouponOrder)
- $obj1->setCouponOrder($obj2);
+ // Add the $obj1 (Order) to the collection in $obj2 (Currency)
+ $obj2->addOrder($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderAddress rows
+
+ $key3 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = OrderAddressPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ OrderAddressPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj3 (OrderAddress)
+ $obj3->addOrderRelatedByAddressInvoice($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderAddress rows
+
+ $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = OrderAddressPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ OrderAddressPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress)
+ $obj4->addOrderRelatedByAddressDelivery($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderStatus rows
+
+ $key5 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol5);
+ if ($key5 !== null) {
+ $obj5 = OrderStatusPeer::getInstanceFromPool($key5);
+ if (!$obj5) {
+
+ $cls = OrderStatusPeer::getOMClass();
+
+ $obj5 = new $cls();
+ $obj5->hydrate($row, $startcol5);
+ OrderStatusPeer::addInstanceToPool($obj5, $key5);
+ } // if $obj5 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj5 (OrderStatus)
+ $obj5->addOrder($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Order objects pre-filled with all related objects except OrderAddressRelatedByAddressInvoice.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Order objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptOrderAddressRelatedByAddressInvoice(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+ }
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
+
+ CurrencyPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderStatusPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = OrderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Currency rows
+
+ $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CurrencyPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CurrencyPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CurrencyPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj2 (Currency)
+ $obj2->addOrder($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Customer rows
+
+ $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CustomerPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CustomerPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CustomerPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj3 (Customer)
+ $obj3->addOrder($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderStatus rows
+
+ $key4 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = OrderStatusPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = OrderStatusPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ OrderStatusPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj4 (OrderStatus)
+ $obj4->addOrder($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Order objects pre-filled with all related objects except OrderAddressRelatedByAddressDelivery.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Order objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptOrderAddressRelatedByAddressDelivery(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+ }
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
+
+ CurrencyPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderStatusPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = OrderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Currency rows
+
+ $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CurrencyPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CurrencyPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CurrencyPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj2 (Currency)
+ $obj2->addOrder($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Customer rows
+
+ $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CustomerPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CustomerPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CustomerPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj3 (Customer)
+ $obj3->addOrder($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderStatus rows
+
+ $key4 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = OrderStatusPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = OrderStatusPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ OrderStatusPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj4 (OrderStatus)
+ $obj4->addOrder($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Order objects pre-filled with all related objects except OrderStatus.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Order objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptOrderStatus(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+ }
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
+
+ CurrencyPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderAddressPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderAddressPeer::addSelectColumns($criteria);
+ $startcol6 = $startcol5 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
+
+ $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = OrderPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Currency rows
+
+ $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CurrencyPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CurrencyPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CurrencyPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj2 (Currency)
+ $obj2->addOrder($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Customer rows
+
+ $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CustomerPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CustomerPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CustomerPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj3 (Customer)
+ $obj3->addOrder($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderAddress rows
+
+ $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = OrderAddressPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ OrderAddressPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress)
+ $obj4->addOrderRelatedByAddressInvoice($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined OrderAddress rows
+
+ $key5 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol5);
+ if ($key5 !== null) {
+ $obj5 = OrderAddressPeer::getInstanceFromPool($key5);
+ if (!$obj5) {
+
+ $cls = OrderAddressPeer::getOMClass();
+
+ $obj5 = new $cls();
+ $obj5->hydrate($row, $startcol5);
+ OrderAddressPeer::addInstanceToPool($obj5, $key5);
+ } // if $obj5 already loaded
+
+ // Add the $obj1 (Order) to the collection in $obj5 (OrderAddress)
+ $obj5->addOrderRelatedByAddressDelivery($obj1);
} // if joined row is not null
@@ -1330,8 +2461,6 @@ abstract class BaseOrderPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += OrderPeer::doOnDeleteCascade(new Criteria(OrderPeer::DATABASE_NAME), $con);
- OrderPeer::doOnDeleteSetNull(new Criteria(OrderPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(OrderPeer::TABLE_NAME, $con, OrderPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -1365,14 +2494,24 @@ abstract class BaseOrderPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ OrderPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Order) { // it's a model object
+ // invalidate the cache for this single object
+ OrderPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(OrderPeer::DATABASE_NAME);
$criteria->add(OrderPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ OrderPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -1385,27 +2524,6 @@ abstract class BaseOrderPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += OrderPeer::doOnDeleteCascade($c, $con);
-
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- OrderPeer::doOnDeleteSetNull($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- OrderPeer::clearInstancePool();
- } elseif ($values instanceof Order) { // it's a model object
- OrderPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- OrderPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
OrderPeer::clearRelatedInstancePool();
$con->commit();
@@ -1417,94 +2535,6 @@ abstract class BaseOrderPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = OrderPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Customer objects
- $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
-
- $criteria->add(CustomerPeer::ID, $obj->getCustomerId());
- $affectedRows += CustomerPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
- /**
- * This is a method for emulating ON DELETE SET NULL DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return void
- */
- protected static function doOnDeleteSetNull(Criteria $criteria, PropelPDO $con)
- {
-
- // first find the objects that are implicated by the $criteria
- $objects = OrderPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
- // set fkey col in related Currency rows to null
- $selectCriteria = new Criteria(OrderPeer::DATABASE_NAME);
- $updateValues = new Criteria(OrderPeer::DATABASE_NAME);
- $selectCriteria->add(CurrencyPeer::ID, $obj->getCurrencyId());
- $updateValues->add(CurrencyPeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- // set fkey col in related OrderAddress rows to null
- $selectCriteria = new Criteria(OrderPeer::DATABASE_NAME);
- $updateValues = new Criteria(OrderPeer::DATABASE_NAME);
- $selectCriteria->add(OrderAddressPeer::ID, $obj->getAddressInvoice());
- $updateValues->add(OrderAddressPeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- // set fkey col in related OrderAddress rows to null
- $selectCriteria = new Criteria(OrderPeer::DATABASE_NAME);
- $updateValues = new Criteria(OrderPeer::DATABASE_NAME);
- $selectCriteria->add(OrderAddressPeer::ID, $obj->getAddressDelivery());
- $updateValues->add(OrderAddressPeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- // set fkey col in related OrderStatus rows to null
- $selectCriteria = new Criteria(OrderPeer::DATABASE_NAME);
- $updateValues = new Criteria(OrderPeer::DATABASE_NAME);
- $selectCriteria->add(OrderStatusPeer::ID, $obj->getStatusId());
- $updateValues->add(OrderStatusPeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- }
- }
-
/**
* Validates all modified columns of given Order object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseOrderProduct.php b/core/lib/Thelia/Model/om/BaseOrderProduct.php
index 088e755b0..191349de4 100644
--- a/core/lib/Thelia/Model/om/BaseOrderProduct.php
+++ b/core/lib/Thelia/Model/om/BaseOrderProduct.php
@@ -124,14 +124,15 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var OrderFeature
+ * @var Order
*/
- protected $aOrderFeature;
+ protected $aOrder;
/**
- * @var Order one-to-one related Order object
+ * @var PropelObjectCollection|OrderFeature[] Collection to store aggregation of OrderFeature objects.
*/
- protected $singleOrder;
+ protected $collOrderFeatures;
+ protected $collOrderFeaturesPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -151,7 +152,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $ordersScheduledForDeletion = null;
+ protected $orderFeaturesScheduledForDeletion = null;
/**
* Get the [id] column value.
@@ -344,10 +345,6 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderProductPeer::ID;
}
- if ($this->aOrderFeature !== null && $this->aOrderFeature->getOrderProductId() !== $v) {
- $this->aOrderFeature = null;
- }
-
return $this;
} // setId()
@@ -369,6 +366,10 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderProductPeer::ORDER_ID;
}
+ if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
+ $this->aOrder = null;
+ }
+
return $this;
} // setOrderId()
@@ -662,8 +663,8 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aOrderFeature !== null && $this->id !== $this->aOrderFeature->getOrderProductId()) {
- $this->aOrderFeature = null;
+ if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) {
+ $this->aOrder = null;
}
} // ensureConsistency
@@ -704,8 +705,8 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aOrderFeature = null;
- $this->singleOrder = null;
+ $this->aOrder = null;
+ $this->collOrderFeatures = null;
} // if (deep)
}
@@ -825,11 +826,11 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aOrderFeature !== null) {
- if ($this->aOrderFeature->isModified() || $this->aOrderFeature->isNew()) {
- $affectedRows += $this->aOrderFeature->save($con);
+ if ($this->aOrder !== null) {
+ if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
+ $affectedRows += $this->aOrder->save($con);
}
- $this->setOrderFeature($this->aOrderFeature);
+ $this->setOrder($this->aOrder);
}
if ($this->isNew() || $this->isModified()) {
@@ -843,18 +844,20 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->ordersScheduledForDeletion !== null) {
- if (!$this->ordersScheduledForDeletion->isEmpty()) {
- OrderQuery::create()
- ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->orderFeaturesScheduledForDeletion !== null) {
+ if (!$this->orderFeaturesScheduledForDeletion->isEmpty()) {
+ OrderFeatureQuery::create()
+ ->filterByPrimaryKeys($this->orderFeaturesScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->ordersScheduledForDeletion = null;
+ $this->orderFeaturesScheduledForDeletion = null;
}
}
- if ($this->singleOrder !== null) {
- if (!$this->singleOrder->isDeleted()) {
- $affectedRows += $this->singleOrder->save($con);
+ if ($this->collOrderFeatures !== null) {
+ foreach ($this->collOrderFeatures as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
}
}
@@ -1066,9 +1069,9 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aOrderFeature !== null) {
- if (!$this->aOrderFeature->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aOrderFeature->getValidationFailures());
+ if ($this->aOrder !== null) {
+ if (!$this->aOrder->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
}
}
@@ -1078,9 +1081,11 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
}
- if ($this->singleOrder !== null) {
- if (!$this->singleOrder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleOrder->getValidationFailures());
+ if ($this->collOrderFeatures !== null) {
+ foreach ($this->collOrderFeatures as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
}
}
@@ -1198,11 +1203,11 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
$keys[11] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aOrderFeature) {
- $result['OrderFeature'] = $this->aOrderFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aOrder) {
+ $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleOrder) {
- $result['Order'] = $this->singleOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collOrderFeatures) {
+ $result['OrderFeatures'] = $this->collOrderFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1415,14 +1420,10 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getOrder();
- if ($relObj) {
- $copyObj->setOrder($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getOrderFeature();
- if ($relObj) {
- $copyObj->setOrderFeature($relObj->copy($deepCopy));
+ foreach ($this->getOrderFeatures() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderFeature($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1476,25 +1477,26 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a OrderFeature object.
+ * Declares an association between this object and a Order object.
*
- * @param OrderFeature $v
+ * @param Order $v
* @return OrderProduct The current object (for fluent API support)
* @throws PropelException
*/
- public function setOrderFeature(OrderFeature $v = null)
+ public function setOrder(Order $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setOrderId(NULL);
} else {
- $this->setId($v->getOrderProductId());
+ $this->setOrderId($v->getId());
}
- $this->aOrderFeature = $v;
+ $this->aOrder = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Order object, it will not be re-added.
if ($v !== null) {
- $v->setOrderProduct($this);
+ $v->addOrderProduct($this);
}
@@ -1503,23 +1505,26 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
/**
- * Get the associated OrderFeature object
+ * Get the associated Order object
*
* @param PropelPDO $con Optional Connection object.
- * @return OrderFeature The associated OrderFeature object.
+ * @return Order The associated Order object.
* @throws PropelException
*/
- public function getOrderFeature(PropelPDO $con = null)
+ public function getOrder(PropelPDO $con = null)
{
- if ($this->aOrderFeature === null && ($this->id !== null)) {
- $this->aOrderFeature = OrderFeatureQuery::create()
- ->filterByOrderProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aOrderFeature->setOrderProduct($this);
+ if ($this->aOrder === null && ($this->order_id !== null)) {
+ $this->aOrder = OrderQuery::create()->findPk($this->order_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->aOrder->addOrderProducts($this);
+ */
}
- return $this->aOrderFeature;
+ return $this->aOrder;
}
@@ -1533,44 +1538,218 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ if ('OrderFeature' == $relationName) {
+ $this->initOrderFeatures();
+ }
}
/**
- * Gets a single Order object, which is related to this object by a one-to-one relationship.
+ * Clears out the collOrderFeatures 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 addOrderFeatures()
+ */
+ public function clearOrderFeatures()
+ {
+ $this->collOrderFeatures = null; // important to set this to null since that means it is uninitialized
+ $this->collOrderFeaturesPartial = null;
+ }
+
+ /**
+ * reset is the collOrderFeatures collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialOrderFeatures($v = true)
+ {
+ $this->collOrderFeaturesPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderFeatures collection.
+ *
+ * By default this just sets the collOrderFeatures collection to an empty array (like clearcollOrderFeatures());
+ * 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 initOrderFeatures($overrideExisting = true)
+ {
+ if (null !== $this->collOrderFeatures && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderFeatures = new PropelObjectCollection();
+ $this->collOrderFeatures->setModel('OrderFeature');
+ }
+
+ /**
+ * Gets an array of OrderFeature 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 OrderProduct 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 Order
+ * @return PropelObjectCollection|OrderFeature[] List of OrderFeature objects
* @throws PropelException
*/
- public function getOrder(PropelPDO $con = null)
+ public function getOrderFeatures($criteria = null, PropelPDO $con = null)
{
+ $partial = $this->collOrderFeaturesPartial && !$this->isNew();
+ if (null === $this->collOrderFeatures || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderFeatures) {
+ // return empty collection
+ $this->initOrderFeatures();
+ } else {
+ $collOrderFeatures = OrderFeatureQuery::create(null, $criteria)
+ ->filterByOrderProduct($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collOrderFeaturesPartial && count($collOrderFeatures)) {
+ $this->initOrderFeatures(false);
- if ($this->singleOrder === null && !$this->isNew()) {
- $this->singleOrder = OrderQuery::create()->findPk($this->getPrimaryKey(), $con);
+ foreach($collOrderFeatures as $obj) {
+ if (false == $this->collOrderFeatures->contains($obj)) {
+ $this->collOrderFeatures->append($obj);
+ }
+ }
+
+ $this->collOrderFeaturesPartial = true;
+ }
+
+ return $collOrderFeatures;
+ }
+
+ if($partial && $this->collOrderFeatures) {
+ foreach($this->collOrderFeatures as $obj) {
+ if($obj->isNew()) {
+ $collOrderFeatures[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderFeatures = $collOrderFeatures;
+ $this->collOrderFeaturesPartial = false;
+ }
}
- return $this->singleOrder;
+ return $this->collOrderFeatures;
}
/**
- * Sets a single Order object as related to this object by a one-to-one relationship.
+ * Sets a collection of OrderFeature 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 Order $v Order
- * @return OrderProduct The current object (for fluent API support)
+ * @param PropelCollection $orderFeatures A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setOrderFeatures(PropelCollection $orderFeatures, PropelPDO $con = null)
+ {
+ $this->orderFeaturesScheduledForDeletion = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures);
+
+ foreach ($this->orderFeaturesScheduledForDeletion as $orderFeatureRemoved) {
+ $orderFeatureRemoved->setOrderProduct(null);
+ }
+
+ $this->collOrderFeatures = null;
+ foreach ($orderFeatures as $orderFeature) {
+ $this->addOrderFeature($orderFeature);
+ }
+
+ $this->collOrderFeatures = $orderFeatures;
+ $this->collOrderFeaturesPartial = false;
+ }
+
+ /**
+ * Returns the number of related OrderFeature objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related OrderFeature objects.
* @throws PropelException
*/
- public function setOrder(Order $v = null)
+ public function countOrderFeatures(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleOrder = $v;
+ $partial = $this->collOrderFeaturesPartial && !$this->isNew();
+ if (null === $this->collOrderFeatures || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderFeatures) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getOrderFeatures());
+ }
+ $query = OrderFeatureQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
- // Make sure that that the passed-in Order isn't already associated with this object
- if ($v !== null && $v->getOrderProduct() === null) {
- $v->setOrderProduct($this);
+ return $query
+ ->filterByOrderProduct($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collOrderFeatures);
+ }
+ }
+
+ /**
+ * Method called to associate a OrderFeature object to this object
+ * through the OrderFeature foreign key attribute.
+ *
+ * @param OrderFeature $l OrderFeature
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function addOrderFeature(OrderFeature $l)
+ {
+ if ($this->collOrderFeatures === null) {
+ $this->initOrderFeatures();
+ $this->collOrderFeaturesPartial = true;
+ }
+ if (!$this->collOrderFeatures->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderFeature($l);
}
return $this;
}
+ /**
+ * @param OrderFeature $orderFeature The orderFeature object to add.
+ */
+ protected function doAddOrderFeature($orderFeature)
+ {
+ $this->collOrderFeatures[]= $orderFeature;
+ $orderFeature->setOrderProduct($this);
+ }
+
+ /**
+ * @param OrderFeature $orderFeature The orderFeature object to remove.
+ */
+ public function removeOrderFeature($orderFeature)
+ {
+ if ($this->getOrderFeatures()->contains($orderFeature)) {
+ $this->collOrderFeatures->remove($this->collOrderFeatures->search($orderFeature));
+ if (null === $this->orderFeaturesScheduledForDeletion) {
+ $this->orderFeaturesScheduledForDeletion = clone $this->collOrderFeatures;
+ $this->orderFeaturesScheduledForDeletion->clear();
+ }
+ $this->orderFeaturesScheduledForDeletion[]= $orderFeature;
+ $orderFeature->setOrderProduct(null);
+ }
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1608,16 +1787,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleOrder) {
- $this->singleOrder->clearAllReferences($deep);
+ if ($this->collOrderFeatures) {
+ foreach ($this->collOrderFeatures as $o) {
+ $o->clearAllReferences($deep);
+ }
}
} // if ($deep)
- if ($this->singleOrder instanceof PropelCollection) {
- $this->singleOrder->clearIterator();
+ if ($this->collOrderFeatures instanceof PropelCollection) {
+ $this->collOrderFeatures->clearIterator();
}
- $this->singleOrder = null;
- $this->aOrderFeature = null;
+ $this->collOrderFeatures = null;
+ $this->aOrder = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseOrderProductPeer.php b/core/lib/Thelia/Model/om/BaseOrderProductPeer.php
index ed990c474..35a94e6c3 100644
--- a/core/lib/Thelia/Model/om/BaseOrderProductPeer.php
+++ b/core/lib/Thelia/Model/om/BaseOrderProductPeer.php
@@ -26,7 +26,7 @@ abstract class BaseOrderProductPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'order_product';
@@ -419,9 +419,9 @@ abstract class BaseOrderProductPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in OrderPeer instance pool,
+ // Invalidate objects in OrderFeaturePeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- OrderPeer::clearInstancePool();
+ OrderFeaturePeer::clearInstancePool();
}
/**
@@ -520,7 +520,7 @@ abstract class BaseOrderProductPeer
/**
- * Returns the number of rows matching criteria, joining the related OrderFeature table
+ * Returns the number of rows matching criteria, joining the related Order table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -528,7 +528,7 @@ abstract class BaseOrderProductPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinOrderFeature(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinOrder(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;
@@ -555,7 +555,7 @@ abstract class BaseOrderProductPeer
$con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(OrderProductPeer::ID, OrderFeaturePeer::ORDER_PRODUCT_ID, $join_behavior);
+ $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -571,7 +571,7 @@ abstract class BaseOrderProductPeer
/**
- * Selects a collection of OrderProduct objects pre-filled with their OrderFeature objects.
+ * Selects a collection of OrderProduct objects pre-filled with their Order objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -579,7 +579,7 @@ abstract class BaseOrderProductPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinOrderFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -590,9 +590,9 @@ abstract class BaseOrderProductPeer
OrderProductPeer::addSelectColumns($criteria);
$startcol = OrderProductPeer::NUM_HYDRATE_COLUMNS;
- OrderFeaturePeer::addSelectColumns($criteria);
+ OrderPeer::addSelectColumns($criteria);
- $criteria->addJoin(OrderProductPeer::ID, OrderFeaturePeer::ORDER_PRODUCT_ID, $join_behavior);
+ $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -612,21 +612,20 @@ abstract class BaseOrderProductPeer
OrderProductPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = OrderFeaturePeer::getInstanceFromPool($key2);
+ $obj2 = OrderPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = OrderFeaturePeer::getOMClass();
+ $cls = OrderPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- OrderFeaturePeer::addInstanceToPool($obj2, $key2);
+ OrderPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (OrderProduct) to $obj2 (OrderFeature)
- // one to one relationship
- $obj1->setOrderFeature($obj2);
+ // Add the $obj1 (OrderProduct) to $obj2 (Order)
+ $obj2->addOrderProduct($obj1);
} // if joined row was not null
@@ -674,7 +673,7 @@ abstract class BaseOrderProductPeer
$con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(OrderProductPeer::ID, OrderFeaturePeer::ORDER_PRODUCT_ID, $join_behavior);
+ $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -710,10 +709,10 @@ abstract class BaseOrderProductPeer
OrderProductPeer::addSelectColumns($criteria);
$startcol2 = OrderProductPeer::NUM_HYDRATE_COLUMNS;
- OrderFeaturePeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + OrderFeaturePeer::NUM_HYDRATE_COLUMNS;
+ OrderPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS;
- $criteria->addJoin(OrderProductPeer::ID, OrderFeaturePeer::ORDER_PRODUCT_ID, $join_behavior);
+ $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -732,22 +731,22 @@ abstract class BaseOrderProductPeer
OrderProductPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined OrderFeature rows
+ // Add objects for joined Order rows
- $key2 = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = OrderFeaturePeer::getInstanceFromPool($key2);
+ $obj2 = OrderPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = OrderFeaturePeer::getOMClass();
+ $cls = OrderPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- OrderFeaturePeer::addInstanceToPool($obj2, $key2);
+ OrderPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (OrderProduct) to the collection in $obj2 (OrderFeature)
- $obj1->setOrderFeature($obj2);
+ // Add the $obj1 (OrderProduct) to the collection in $obj2 (Order)
+ $obj2->addOrderProduct($obj1);
} // if joined row not null
$results[] = $obj1;
@@ -890,7 +889,6 @@ abstract class BaseOrderProductPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += OrderProductPeer::doOnDeleteCascade(new Criteria(OrderProductPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(OrderProductPeer::TABLE_NAME, $con, OrderProductPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -924,14 +922,24 @@ abstract class BaseOrderProductPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ OrderProductPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof OrderProduct) { // it's a model object
+ // invalidate the cache for this single object
+ OrderProductPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(OrderProductPeer::DATABASE_NAME);
$criteria->add(OrderProductPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ OrderProductPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -944,23 +952,6 @@ abstract class BaseOrderProductPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += OrderProductPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- OrderProductPeer::clearInstancePool();
- } elseif ($values instanceof OrderProduct) { // it's a model object
- OrderProductPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- OrderProductPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
OrderProductPeer::clearRelatedInstancePool();
$con->commit();
@@ -972,39 +963,6 @@ abstract class BaseOrderProductPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = OrderProductPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Order objects
- $criteria = new Criteria(OrderPeer::DATABASE_NAME);
-
- $criteria->add(OrderPeer::ID, $obj->getOrderId());
- $affectedRows += OrderPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given OrderProduct object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php
index 59125a80f..4c741ee18 100644
--- a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php
+++ b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php
@@ -53,14 +53,14 @@ use Thelia\Model\OrderProductQuery;
* @method OrderProductQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method OrderProductQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method OrderProductQuery leftJoinOrderFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderFeature relation
- * @method OrderProductQuery rightJoinOrderFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderFeature relation
- * @method OrderProductQuery innerJoinOrderFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderFeature relation
- *
* @method OrderProductQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation
* @method OrderProductQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
* @method OrderProductQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
*
+ * @method OrderProductQuery leftJoinOrderFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderFeature relation
+ * @method OrderProductQuery rightJoinOrderFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderFeature relation
+ * @method OrderProductQuery innerJoinOrderFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderFeature relation
+ *
* @method OrderProduct findOne(PropelPDO $con = null) Return the first OrderProduct matching the query
* @method OrderProduct findOneOrCreate(PropelPDO $con = null) Return the first OrderProduct matching the query, or a new OrderProduct object populated from the query conditions when no match is found
*
@@ -101,7 +101,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\OrderProduct', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\OrderProduct', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -277,8 +277,6 @@ abstract class BaseOrderProductQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByOrderFeature()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -306,6 +304,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria
* $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
*
*
+ * @see filterByOrder()
+ *
* @param mixed $orderId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -703,86 +703,10 @@ abstract class BaseOrderProductQuery extends ModelCriteria
return $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt, $comparison);
}
- /**
- * Filter the query by a related OrderFeature object
- *
- * @param OrderFeature|PropelObjectCollection $orderFeature The related object(s) to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return OrderProductQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByOrderFeature($orderFeature, $comparison = null)
- {
- if ($orderFeature instanceof OrderFeature) {
- return $this
- ->addUsingAlias(OrderProductPeer::ID, $orderFeature->getOrderProductId(), $comparison);
- } elseif ($orderFeature instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
- return $this
- ->addUsingAlias(OrderProductPeer::ID, $orderFeature->toKeyValue('PrimaryKey', 'OrderProductId'), $comparison);
- } else {
- throw new PropelException('filterByOrderFeature() only accepts arguments of type OrderFeature or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the OrderFeature relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return OrderProductQuery The current query, for fluid interface
- */
- public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('OrderFeature');
-
- // 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, 'OrderFeature');
- }
-
- return $this;
- }
-
- /**
- * Use the OrderFeature relation OrderFeature 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\OrderFeatureQuery A secondary query class using the current class as primary query
- */
- public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinOrderFeature($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery');
- }
-
/**
* Filter the query by a related Order object
*
- * @param Order|PropelObjectCollection $order the related object to use as filter
+ * @param Order|PropelObjectCollection $order The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderProductQuery The current query, for fluid interface
@@ -794,10 +718,12 @@ abstract class BaseOrderProductQuery extends ModelCriteria
return $this
->addUsingAlias(OrderProductPeer::ORDER_ID, $order->getId(), $comparison);
} elseif ($order instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useOrderQuery()
- ->filterByPrimaryKeys($order->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
}
@@ -853,6 +779,80 @@ abstract class BaseOrderProductQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
}
+ /**
+ * Filter the query by a related OrderFeature object
+ *
+ * @param OrderFeature|PropelObjectCollection $orderFeature the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrderFeature($orderFeature, $comparison = null)
+ {
+ if ($orderFeature instanceof OrderFeature) {
+ return $this
+ ->addUsingAlias(OrderProductPeer::ID, $orderFeature->getOrderProductId(), $comparison);
+ } elseif ($orderFeature instanceof PropelObjectCollection) {
+ return $this
+ ->useOrderFeatureQuery()
+ ->filterByPrimaryKeys($orderFeature->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderFeature() only accepts arguments of type OrderFeature or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderFeature relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderFeature');
+
+ // 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, 'OrderFeature');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderFeature relation OrderFeature 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\OrderFeatureQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderFeature($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseOrderQuery.php b/core/lib/Thelia/Model/om/BaseOrderQuery.php
index b271b0167..c691158b0 100644
--- a/core/lib/Thelia/Model/om/BaseOrderQuery.php
+++ b/core/lib/Thelia/Model/om/BaseOrderQuery.php
@@ -69,14 +69,6 @@ use Thelia\Model\OrderStatus;
* @method OrderQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method OrderQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @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 leftJoinCurrency($relationAlias = null) Adds a LEFT JOIN clause to the query using the Currency relation
* @method OrderQuery rightJoinCurrency($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Currency relation
* @method OrderQuery innerJoinCurrency($relationAlias = null) Adds a INNER JOIN clause to the query using the Currency relation
@@ -85,18 +77,26 @@ use Thelia\Model\OrderStatus;
* @method OrderQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation
* @method OrderQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation
*
- * @method OrderQuery leftJoinOrderAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddress relation
- * @method OrderQuery rightJoinOrderAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddress relation
- * @method OrderQuery innerJoinOrderAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddress relation
+ * @method OrderQuery leftJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation
+ * @method OrderQuery rightJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation
+ * @method OrderQuery innerJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation
*
- * @method OrderQuery leftJoinOrderAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddress relation
- * @method OrderQuery rightJoinOrderAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddress relation
- * @method OrderQuery innerJoinOrderAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddress relation
+ * @method OrderQuery leftJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation
+ * @method OrderQuery rightJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation
+ * @method OrderQuery innerJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation
*
* @method OrderQuery leftJoinOrderStatus($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderStatus relation
* @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 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
*
@@ -149,7 +149,7 @@ abstract class BaseOrderQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Order', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Order', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -325,10 +325,6 @@ abstract class BaseOrderQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByCouponOrder()
- *
- * @see filterByOrderProduct()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -385,6 +381,8 @@ abstract class BaseOrderQuery extends ModelCriteria
* $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
*
*
+ * @see filterByCustomer()
+ *
* @param mixed $customerId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -426,6 +424,8 @@ abstract class BaseOrderQuery extends ModelCriteria
* $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice > 12
*
*
+ * @see filterByOrderAddressRelatedByAddressInvoice()
+ *
* @param mixed $addressInvoice The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -467,6 +467,8 @@ abstract class BaseOrderQuery extends ModelCriteria
* $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery > 12
*
*
+ * @see filterByOrderAddressRelatedByAddressDelivery()
+ *
* @param mixed $addressDelivery The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -551,6 +553,8 @@ abstract class BaseOrderQuery extends ModelCriteria
* $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id > 12
*
*
+ * @see filterByCurrency()
+ *
* @param mixed $currencyId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -819,6 +823,8 @@ abstract class BaseOrderQuery extends ModelCriteria
* $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12
*
*
+ * @see filterByOrderStatus()
+ *
* @param mixed $statusId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -965,162 +971,10 @@ abstract class BaseOrderQuery extends ModelCriteria
return $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt, $comparison);
}
- /**
- * Filter the query by a related CouponOrder object
- *
- * @param CouponOrder|PropelObjectCollection $couponOrder The related object(s) to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return OrderQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByCouponOrder($couponOrder, $comparison = null)
- {
- if ($couponOrder instanceof CouponOrder) {
- return $this
- ->addUsingAlias(OrderPeer::ID, $couponOrder->getOrderId(), $comparison);
- } elseif ($couponOrder instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
- return $this
- ->addUsingAlias(OrderPeer::ID, $couponOrder->toKeyValue('PrimaryKey', 'OrderId'), $comparison);
- } 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
- *
- * @param OrderProduct|PropelObjectCollection $orderProduct The related object(s) to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return OrderQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByOrderProduct($orderProduct, $comparison = null)
- {
- if ($orderProduct instanceof OrderProduct) {
- return $this
- ->addUsingAlias(OrderPeer::ID, $orderProduct->getOrderId(), $comparison);
- } elseif ($orderProduct instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
- return $this
- ->addUsingAlias(OrderPeer::ID, $orderProduct->toKeyValue('PrimaryKey', 'OrderId'), $comparison);
- } else {
- throw new PropelException('filterByOrderProduct() only accepts arguments of type OrderProduct or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the OrderProduct 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 joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('OrderProduct');
-
- // 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, 'OrderProduct');
- }
-
- return $this;
- }
-
- /**
- * Use the OrderProduct relation OrderProduct 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\OrderProductQuery A secondary query class using the current class as primary query
- */
- public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinOrderProduct($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery');
- }
-
/**
* Filter the query by a related Currency object
*
- * @param Currency|PropelObjectCollection $currency the related object to use as filter
+ * @param Currency|PropelObjectCollection $currency The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderQuery The current query, for fluid interface
@@ -1132,10 +986,12 @@ abstract class BaseOrderQuery extends ModelCriteria
return $this
->addUsingAlias(OrderPeer::CURRENCY_ID, $currency->getId(), $comparison);
} elseif ($currency instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCurrencyQuery()
- ->filterByPrimaryKeys($currency->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(OrderPeer::CURRENCY_ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCurrency() only accepts arguments of type Currency or PropelCollection');
}
@@ -1149,7 +1005,7 @@ abstract class BaseOrderQuery extends ModelCriteria
*
* @return OrderQuery The current query, for fluid interface
*/
- public function joinCurrency($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinCurrency($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Currency');
@@ -1184,7 +1040,7 @@ abstract class BaseOrderQuery extends ModelCriteria
*
* @return \Thelia\Model\CurrencyQuery A secondary query class using the current class as primary query
*/
- public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinCurrency($relationAlias, $joinType)
@@ -1194,7 +1050,7 @@ abstract class BaseOrderQuery extends ModelCriteria
/**
* Filter the query by a related Customer object
*
- * @param Customer|PropelObjectCollection $customer the related object to use as filter
+ * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderQuery The current query, for fluid interface
@@ -1206,10 +1062,12 @@ abstract class BaseOrderQuery extends ModelCriteria
return $this
->addUsingAlias(OrderPeer::CUSTOMER_ID, $customer->getId(), $comparison);
} elseif ($customer instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCustomerQuery()
- ->filterByPrimaryKeys($customer->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(OrderPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
}
@@ -1268,39 +1126,41 @@ abstract class BaseOrderQuery extends ModelCriteria
/**
* Filter the query by a related OrderAddress object
*
- * @param OrderAddress|PropelObjectCollection $orderAddress the related object to use as filter
+ * @param OrderAddress|PropelObjectCollection $orderAddress The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByOrderAddress($orderAddress, $comparison = null)
+ public function filterByOrderAddressRelatedByAddressInvoice($orderAddress, $comparison = null)
{
if ($orderAddress instanceof OrderAddress) {
return $this
->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $orderAddress->getId(), $comparison);
} elseif ($orderAddress instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useOrderAddressQuery()
- ->filterByPrimaryKeys($orderAddress->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
- throw new PropelException('filterByOrderAddress() only accepts arguments of type OrderAddress or PropelCollection');
+ throw new PropelException('filterByOrderAddressRelatedByAddressInvoice() only accepts arguments of type OrderAddress or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the OrderAddress relation
+ * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressInvoice 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 joinOrderAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinOrderAddressRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('OrderAddress');
+ $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressInvoice');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -1315,14 +1175,14 @@ abstract class BaseOrderQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'OrderAddress');
+ $this->addJoinObject($join, 'OrderAddressRelatedByAddressInvoice');
}
return $this;
}
/**
- * Use the OrderAddress relation OrderAddress object
+ * Use the OrderAddressRelatedByAddressInvoice relation OrderAddress object
*
* @see useQuery()
*
@@ -1332,49 +1192,51 @@ abstract class BaseOrderQuery extends ModelCriteria
*
* @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query
*/
- public function useOrderAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useOrderAddressRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
- ->joinOrderAddress($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'OrderAddress', '\Thelia\Model\OrderAddressQuery');
+ ->joinOrderAddressRelatedByAddressInvoice($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressInvoice', '\Thelia\Model\OrderAddressQuery');
}
/**
* Filter the query by a related OrderAddress object
*
- * @param OrderAddress|PropelObjectCollection $orderAddress the related object to use as filter
+ * @param OrderAddress|PropelObjectCollection $orderAddress The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByOrderAddress($orderAddress, $comparison = null)
+ public function filterByOrderAddressRelatedByAddressDelivery($orderAddress, $comparison = null)
{
if ($orderAddress instanceof OrderAddress) {
return $this
->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $orderAddress->getId(), $comparison);
} elseif ($orderAddress instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useOrderAddressQuery()
- ->filterByPrimaryKeys($orderAddress->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
- throw new PropelException('filterByOrderAddress() only accepts arguments of type OrderAddress or PropelCollection');
+ throw new PropelException('filterByOrderAddressRelatedByAddressDelivery() only accepts arguments of type OrderAddress or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the OrderAddress relation
+ * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressDelivery 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 joinOrderAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinOrderAddressRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('OrderAddress');
+ $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressDelivery');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -1389,14 +1251,14 @@ abstract class BaseOrderQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'OrderAddress');
+ $this->addJoinObject($join, 'OrderAddressRelatedByAddressDelivery');
}
return $this;
}
/**
- * Use the OrderAddress relation OrderAddress object
+ * Use the OrderAddressRelatedByAddressDelivery relation OrderAddress object
*
* @see useQuery()
*
@@ -1406,17 +1268,17 @@ abstract class BaseOrderQuery extends ModelCriteria
*
* @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query
*/
- public function useOrderAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useOrderAddressRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
- ->joinOrderAddress($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'OrderAddress', '\Thelia\Model\OrderAddressQuery');
+ ->joinOrderAddressRelatedByAddressDelivery($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressDelivery', '\Thelia\Model\OrderAddressQuery');
}
/**
* Filter the query by a related OrderStatus object
*
- * @param OrderStatus|PropelObjectCollection $orderStatus the related object to use as filter
+ * @param OrderStatus|PropelObjectCollection $orderStatus The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderQuery The current query, for fluid interface
@@ -1428,10 +1290,12 @@ abstract class BaseOrderQuery extends ModelCriteria
return $this
->addUsingAlias(OrderPeer::STATUS_ID, $orderStatus->getId(), $comparison);
} elseif ($orderStatus instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useOrderStatusQuery()
- ->filterByPrimaryKeys($orderStatus->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(OrderPeer::STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByOrderStatus() only accepts arguments of type OrderStatus or PropelCollection');
}
@@ -1445,7 +1309,7 @@ abstract class BaseOrderQuery extends ModelCriteria
*
* @return OrderQuery The current query, for fluid interface
*/
- public function joinOrderStatus($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinOrderStatus($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('OrderStatus');
@@ -1480,13 +1344,161 @@ abstract class BaseOrderQuery extends ModelCriteria
*
* @return \Thelia\Model\OrderStatusQuery A secondary query class using the current class as primary query
*/
- public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinOrderStatus($relationAlias, $joinType)
->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
+ *
+ * @param OrderProduct|PropelObjectCollection $orderProduct the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrderProduct($orderProduct, $comparison = null)
+ {
+ if ($orderProduct instanceof OrderProduct) {
+ return $this
+ ->addUsingAlias(OrderPeer::ID, $orderProduct->getOrderId(), $comparison);
+ } elseif ($orderProduct instanceof PropelObjectCollection) {
+ return $this
+ ->useOrderProductQuery()
+ ->filterByPrimaryKeys($orderProduct->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderProduct() only accepts arguments of type OrderProduct or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderProduct 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 joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderProduct');
+
+ // 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, 'OrderProduct');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderProduct relation OrderProduct 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\OrderProductQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatus.php b/core/lib/Thelia/Model/om/BaseOrderStatus.php
index 98f9e2403..62c14b0fe 100644
--- a/core/lib/Thelia/Model/om/BaseOrderStatus.php
+++ b/core/lib/Thelia/Model/om/BaseOrderStatus.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Order;
use Thelia\Model\OrderQuery;
@@ -74,14 +76,16 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Order
+ * @var PropelObjectCollection|Order[] Collection to store aggregation of Order objects.
*/
- protected $aOrder;
+ protected $collOrders;
+ protected $collOrdersPartial;
/**
- * @var OrderStatusDesc
+ * @var PropelObjectCollection|OrderStatusDesc[] Collection to store aggregation of OrderStatusDesc objects.
*/
- protected $aOrderStatusDesc;
+ protected $collOrderStatusDescs;
+ protected $collOrderStatusDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -97,6 +101,18 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $ordersScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $orderStatusDescsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -208,14 +224,6 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderStatusPeer::ID;
}
- if ($this->aOrder !== null && $this->aOrder->getStatusId() !== $v) {
- $this->aOrder = null;
- }
-
- if ($this->aOrderStatusDesc !== null && $this->aOrderStatusDesc->getStatusId() !== $v) {
- $this->aOrderStatusDesc = null;
- }
-
return $this;
} // setId()
@@ -354,12 +362,6 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aOrder !== null && $this->id !== $this->aOrder->getStatusId()) {
- $this->aOrder = null;
- }
- if ($this->aOrderStatusDesc !== null && $this->id !== $this->aOrderStatusDesc->getStatusId()) {
- $this->aOrderStatusDesc = null;
- }
} // ensureConsistency
/**
@@ -399,8 +401,10 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aOrder = null;
- $this->aOrderStatusDesc = null;
+ $this->collOrders = null;
+
+ $this->collOrderStatusDescs = null;
+
} // if (deep)
}
@@ -514,25 +518,6 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aOrder !== null) {
- if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
- $affectedRows += $this->aOrder->save($con);
- }
- $this->setOrder($this->aOrder);
- }
-
- if ($this->aOrderStatusDesc !== null) {
- if ($this->aOrderStatusDesc->isModified() || $this->aOrderStatusDesc->isNew()) {
- $affectedRows += $this->aOrderStatusDesc->save($con);
- }
- $this->setOrderStatusDesc($this->aOrderStatusDesc);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -544,6 +529,41 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->ordersScheduledForDeletion !== null) {
+ if (!$this->ordersScheduledForDeletion->isEmpty()) {
+ foreach ($this->ordersScheduledForDeletion as $order) {
+ // need to save related object because we set the relation to null
+ $order->save($con);
+ }
+ $this->ordersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->orderStatusDescsScheduledForDeletion !== null) {
+ if (!$this->orderStatusDescsScheduledForDeletion->isEmpty()) {
+ OrderStatusDescQuery::create()
+ ->filterByPrimaryKeys($this->orderStatusDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderStatusDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderStatusDescs !== null) {
+ foreach ($this->collOrderStatusDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -699,29 +719,27 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aOrder !== null) {
- if (!$this->aOrder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
- }
- }
-
- if ($this->aOrderStatusDesc !== null) {
- if (!$this->aOrderStatusDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aOrderStatusDesc->getValidationFailures());
- }
- }
-
-
if (($retval = OrderStatusPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collOrderStatusDescs !== null) {
+ foreach ($this->collOrderStatusDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -804,11 +822,11 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
$keys[3] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aOrder) {
- $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aOrderStatusDesc) {
- $result['OrderStatusDesc'] = $this->aOrderStatusDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collOrderStatusDescs) {
+ $result['OrderStatusDescs'] = $this->collOrderStatusDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -973,14 +991,16 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getOrder();
- if ($relObj) {
- $copyObj->setOrder($relObj->copy($deepCopy));
+ foreach ($this->getOrders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrder($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getOrderStatusDesc();
- if ($relObj) {
- $copyObj->setOrderStatusDesc($relObj->copy($deepCopy));
+ foreach ($this->getOrderStatusDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderStatusDesc($relObj->copy($deepCopy));
+ }
}
//unflag object copy
@@ -1033,98 +1053,537 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a Order object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param Order $v
- * @return OrderStatus The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Order' == $relationName) {
+ $this->initOrders();
+ }
+ if ('OrderStatusDesc' == $relationName) {
+ $this->initOrderStatusDescs();
+ }
+ }
+
+ /**
+ * Clears out the collOrders 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 addOrders()
+ */
+ public function clearOrders()
+ {
+ $this->collOrders = null; // important to set this to null since that means it is uninitialized
+ $this->collOrdersPartial = null;
+ }
+
+ /**
+ * reset is the collOrders collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialOrders($v = true)
+ {
+ $this->collOrdersPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrders collection.
+ *
+ * By default this just sets the collOrders collection to an empty array (like clearcollOrders());
+ * 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 initOrders($overrideExisting = true)
+ {
+ if (null !== $this->collOrders && !$overrideExisting) {
+ return;
+ }
+ $this->collOrders = new PropelObjectCollection();
+ $this->collOrders->setModel('Order');
+ }
+
+ /**
+ * Gets an array of Order 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 OrderStatus 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|Order[] List of Order objects
* @throws PropelException
*/
- public function setOrder(Order $v = null)
+ public function getOrders($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ // return empty collection
+ $this->initOrders();
+ } else {
+ $collOrders = OrderQuery::create(null, $criteria)
+ ->filterByOrderStatus($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersPartial && count($collOrders)) {
+ $this->initOrders(false);
+
+ foreach($collOrders as $obj) {
+ if (false == $this->collOrders->contains($obj)) {
+ $this->collOrders->append($obj);
+ }
+ }
+
+ $this->collOrdersPartial = true;
+ }
+
+ return $collOrders;
+ }
+
+ if($partial && $this->collOrders) {
+ foreach($this->collOrders as $obj) {
+ if($obj->isNew()) {
+ $collOrders[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrders = $collOrders;
+ $this->collOrdersPartial = false;
+ }
+ }
+
+ return $this->collOrders;
+ }
+
+ /**
+ * Sets a collection of Order 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 $orders A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setOrders(PropelCollection $orders, PropelPDO $con = null)
+ {
+ $this->ordersScheduledForDeletion = $this->getOrders(new Criteria(), $con)->diff($orders);
+
+ foreach ($this->ordersScheduledForDeletion as $orderRemoved) {
+ $orderRemoved->setOrderStatus(null);
+ }
+
+ $this->collOrders = null;
+ foreach ($orders as $order) {
+ $this->addOrder($order);
+ }
+
+ $this->collOrders = $orders;
+ $this->collOrdersPartial = false;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getOrders());
+ }
+ $query = OrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderStatus($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getStatusId());
+ return count($this->collOrders);
}
+ }
- $this->aOrder = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setOrderStatus($this);
+ /**
+ * Method called to associate a Order object to this object
+ * through the Order foreign key attribute.
+ *
+ * @param Order $l Order
+ * @return OrderStatus The current object (for fluent API support)
+ */
+ public function addOrder(Order $l)
+ {
+ if ($this->collOrders === null) {
+ $this->initOrders();
+ $this->collOrdersPartial = true;
+ }
+ if (!$this->collOrders->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddOrder($l);
}
-
return $this;
}
-
/**
- * Get the associated Order object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Order The associated Order object.
- * @throws PropelException
+ * @param Order $order The order object to add.
*/
- public function getOrder(PropelPDO $con = null)
+ protected function doAddOrder($order)
{
- if ($this->aOrder === null && ($this->id !== null)) {
- $this->aOrder = OrderQuery::create()
- ->filterByOrderStatus($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aOrder->setOrderStatus($this);
- }
-
- return $this->aOrder;
+ $this->collOrders[]= $order;
+ $order->setOrderStatus($this);
}
/**
- * Declares an association between this object and a OrderStatusDesc object.
+ * @param Order $order The order object to remove.
+ */
+ public function removeOrder($order)
+ {
+ if ($this->getOrders()->contains($order)) {
+ $this->collOrders->remove($this->collOrders->search($order));
+ if (null === $this->ordersScheduledForDeletion) {
+ $this->ordersScheduledForDeletion = clone $this->collOrders;
+ $this->ordersScheduledForDeletion->clear();
+ }
+ $this->ordersScheduledForDeletion[]= $order;
+ $order->setOrderStatus(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderStatus is new, it will return
+ * an empty collection; or if this OrderStatus has previously
+ * been saved, it will retrieve related Orders from storage.
*
- * @param OrderStatusDesc $v
- * @return OrderStatus The current object (for fluent API support)
+ * 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 OrderStatus.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('Currency', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderStatus is new, it will return
+ * an empty collection; or if this OrderStatus has previously
+ * been saved, it will retrieve related Orders 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 OrderStatus.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('Customer', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderStatus is new, it will return
+ * an empty collection; or if this OrderStatus has previously
+ * been saved, it will retrieve related Orders 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 OrderStatus.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderStatus is new, it will return
+ * an empty collection; or if this OrderStatus has previously
+ * been saved, it will retrieve related Orders 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 OrderStatus.
+ *
+ * @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|Order[] List of Order objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = OrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+ /**
+ * Clears out the collOrderStatusDescs 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 addOrderStatusDescs()
+ */
+ public function clearOrderStatusDescs()
+ {
+ $this->collOrderStatusDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collOrderStatusDescsPartial = null;
+ }
+
+ /**
+ * reset is the collOrderStatusDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialOrderStatusDescs($v = true)
+ {
+ $this->collOrderStatusDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderStatusDescs collection.
+ *
+ * By default this just sets the collOrderStatusDescs collection to an empty array (like clearcollOrderStatusDescs());
+ * 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 initOrderStatusDescs($overrideExisting = true)
+ {
+ if (null !== $this->collOrderStatusDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderStatusDescs = new PropelObjectCollection();
+ $this->collOrderStatusDescs->setModel('OrderStatusDesc');
+ }
+
+ /**
+ * Gets an array of OrderStatusDesc 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 OrderStatus 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|OrderStatusDesc[] List of OrderStatusDesc objects
* @throws PropelException
*/
- public function setOrderStatusDesc(OrderStatusDesc $v = null)
+ public function getOrderStatusDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collOrderStatusDescsPartial && !$this->isNew();
+ if (null === $this->collOrderStatusDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderStatusDescs) {
+ // return empty collection
+ $this->initOrderStatusDescs();
+ } else {
+ $collOrderStatusDescs = OrderStatusDescQuery::create(null, $criteria)
+ ->filterByOrderStatus($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collOrderStatusDescsPartial && count($collOrderStatusDescs)) {
+ $this->initOrderStatusDescs(false);
+
+ foreach($collOrderStatusDescs as $obj) {
+ if (false == $this->collOrderStatusDescs->contains($obj)) {
+ $this->collOrderStatusDescs->append($obj);
+ }
+ }
+
+ $this->collOrderStatusDescsPartial = true;
+ }
+
+ return $collOrderStatusDescs;
+ }
+
+ if($partial && $this->collOrderStatusDescs) {
+ foreach($this->collOrderStatusDescs as $obj) {
+ if($obj->isNew()) {
+ $collOrderStatusDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderStatusDescs = $collOrderStatusDescs;
+ $this->collOrderStatusDescsPartial = false;
+ }
+ }
+
+ return $this->collOrderStatusDescs;
+ }
+
+ /**
+ * Sets a collection of OrderStatusDesc 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 $orderStatusDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setOrderStatusDescs(PropelCollection $orderStatusDescs, PropelPDO $con = null)
+ {
+ $this->orderStatusDescsScheduledForDeletion = $this->getOrderStatusDescs(new Criteria(), $con)->diff($orderStatusDescs);
+
+ foreach ($this->orderStatusDescsScheduledForDeletion as $orderStatusDescRemoved) {
+ $orderStatusDescRemoved->setOrderStatus(null);
+ }
+
+ $this->collOrderStatusDescs = null;
+ foreach ($orderStatusDescs as $orderStatusDesc) {
+ $this->addOrderStatusDesc($orderStatusDesc);
+ }
+
+ $this->collOrderStatusDescs = $orderStatusDescs;
+ $this->collOrderStatusDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related OrderStatusDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related OrderStatusDesc objects.
+ * @throws PropelException
+ */
+ public function countOrderStatusDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collOrderStatusDescsPartial && !$this->isNew();
+ if (null === $this->collOrderStatusDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderStatusDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getOrderStatusDescs());
+ }
+ $query = OrderStatusDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderStatus($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getStatusId());
+ return count($this->collOrderStatusDescs);
}
+ }
- $this->aOrderStatusDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setOrderStatus($this);
+ /**
+ * Method called to associate a OrderStatusDesc object to this object
+ * through the OrderStatusDesc foreign key attribute.
+ *
+ * @param OrderStatusDesc $l OrderStatusDesc
+ * @return OrderStatus The current object (for fluent API support)
+ */
+ public function addOrderStatusDesc(OrderStatusDesc $l)
+ {
+ if ($this->collOrderStatusDescs === null) {
+ $this->initOrderStatusDescs();
+ $this->collOrderStatusDescsPartial = true;
+ }
+ if (!$this->collOrderStatusDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderStatusDesc($l);
}
-
return $this;
}
+ /**
+ * @param OrderStatusDesc $orderStatusDesc The orderStatusDesc object to add.
+ */
+ protected function doAddOrderStatusDesc($orderStatusDesc)
+ {
+ $this->collOrderStatusDescs[]= $orderStatusDesc;
+ $orderStatusDesc->setOrderStatus($this);
+ }
/**
- * Get the associated OrderStatusDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return OrderStatusDesc The associated OrderStatusDesc object.
- * @throws PropelException
+ * @param OrderStatusDesc $orderStatusDesc The orderStatusDesc object to remove.
*/
- public function getOrderStatusDesc(PropelPDO $con = null)
+ public function removeOrderStatusDesc($orderStatusDesc)
{
- if ($this->aOrderStatusDesc === null && ($this->id !== null)) {
- $this->aOrderStatusDesc = OrderStatusDescQuery::create()
- ->filterByOrderStatus($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aOrderStatusDesc->setOrderStatus($this);
+ if ($this->getOrderStatusDescs()->contains($orderStatusDesc)) {
+ $this->collOrderStatusDescs->remove($this->collOrderStatusDescs->search($orderStatusDesc));
+ if (null === $this->orderStatusDescsScheduledForDeletion) {
+ $this->orderStatusDescsScheduledForDeletion = clone $this->collOrderStatusDescs;
+ $this->orderStatusDescsScheduledForDeletion->clear();
+ }
+ $this->orderStatusDescsScheduledForDeletion[]= $orderStatusDesc;
+ $orderStatusDesc->setOrderStatus(null);
}
-
- return $this->aOrderStatusDesc;
}
/**
@@ -1156,10 +1615,26 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collOrders) {
+ foreach ($this->collOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrderStatusDescs) {
+ foreach ($this->collOrderStatusDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aOrder = null;
- $this->aOrderStatusDesc = null;
+ if ($this->collOrders instanceof PropelCollection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
+ if ($this->collOrderStatusDescs instanceof PropelCollection) {
+ $this->collOrderStatusDescs->clearIterator();
+ }
+ $this->collOrderStatusDescs = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php b/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php
index cbcaeacf5..63d7b25f6 100644
--- a/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\OrderStatus;
use Thelia\Model\OrderStatusDesc;
@@ -98,9 +96,9 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var OrderStatus one-to-one related OrderStatus object
+ * @var OrderStatus
*/
- protected $singleOrderStatus;
+ protected $aOrderStatus;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -116,12 +114,6 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $orderStatussScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -294,6 +286,10 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = OrderStatusDescPeer::STATUS_ID;
}
+ if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) {
+ $this->aOrderStatus = null;
+ }
+
return $this;
} // setStatusId()
@@ -499,6 +495,9 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aOrderStatus !== null && $this->status_id !== $this->aOrderStatus->getId()) {
+ $this->aOrderStatus = null;
+ }
} // ensureConsistency
/**
@@ -538,8 +537,7 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleOrderStatus = null;
-
+ $this->aOrderStatus = null;
} // if (deep)
}
@@ -653,6 +651,18 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrderStatus !== null) {
+ if ($this->aOrderStatus->isModified() || $this->aOrderStatus->isNew()) {
+ $affectedRows += $this->aOrderStatus->save($con);
+ }
+ $this->setOrderStatus($this->aOrderStatus);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -664,21 +674,6 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->orderStatussScheduledForDeletion !== null) {
- if (!$this->orderStatussScheduledForDeletion->isEmpty()) {
- OrderStatusQuery::create()
- ->filterByPrimaryKeys($this->orderStatussScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->orderStatussScheduledForDeletion = null;
- }
- }
-
- if ($this->singleOrderStatus !== null) {
- if (!$this->singleOrderStatus->isDeleted()) {
- $affectedRows += $this->singleOrderStatus->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -858,17 +853,23 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrderStatus !== null) {
+ if (!$this->aOrderStatus->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aOrderStatus->getValidationFailures());
+ }
+ }
+
+
if (($retval = OrderStatusDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleOrderStatus !== null) {
- if (!$this->singleOrderStatus->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleOrderStatus->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -967,8 +968,8 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleOrderStatus) {
- $result['OrderStatus'] = $this->singleOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aOrderStatus) {
+ $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1157,11 +1158,6 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getOrderStatus();
- if ($relObj) {
- $copyObj->setOrderStatus($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1212,55 +1208,57 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a OrderStatus object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single OrderStatus object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return OrderStatus
- * @throws PropelException
- */
- public function getOrderStatus(PropelPDO $con = null)
- {
-
- if ($this->singleOrderStatus === null && !$this->isNew()) {
- $this->singleOrderStatus = OrderStatusQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleOrderStatus;
- }
-
- /**
- * Sets a single OrderStatus object as related to this object by a one-to-one relationship.
- *
- * @param OrderStatus $v OrderStatus
+ * @param OrderStatus $v
* @return OrderStatusDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setOrderStatus(OrderStatus $v = null)
{
- $this->singleOrderStatus = $v;
-
- // Make sure that that the passed-in OrderStatus isn't already associated with this object
- if ($v !== null && $v->getOrderStatusDesc() === null) {
- $v->setOrderStatusDesc($this);
+ if ($v === null) {
+ $this->setStatusId(NULL);
+ } else {
+ $this->setStatusId($v->getId());
}
+ $this->aOrderStatus = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the OrderStatus object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderStatusDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated OrderStatus object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return OrderStatus The associated OrderStatus object.
+ * @throws PropelException
+ */
+ public function getOrderStatus(PropelPDO $con = null)
+ {
+ if ($this->aOrderStatus === null && ($this->status_id !== null)) {
+ $this->aOrderStatus = OrderStatusQuery::create()->findPk($this->status_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->aOrderStatus->addOrderStatusDescs($this);
+ */
+ }
+
+ return $this->aOrderStatus;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1294,15 +1292,9 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleOrderStatus) {
- $this->singleOrderStatus->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleOrderStatus instanceof PropelCollection) {
- $this->singleOrderStatus->clearIterator();
- }
- $this->singleOrderStatus = null;
+ $this->aOrderStatus = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusDescPeer.php b/core/lib/Thelia/Model/om/BaseOrderStatusDescPeer.php
index b57a0830c..963cda92b 100644
--- a/core/lib/Thelia/Model/om/BaseOrderStatusDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseOrderStatusDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'order_status_desc';
@@ -398,9 +398,6 @@ abstract class BaseOrderStatusDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in OrderStatusPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- OrderStatusPeer::clearInstancePool();
}
/**
@@ -497,6 +494,244 @@ abstract class BaseOrderStatusDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related OrderStatus table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinOrderStatus(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderStatusDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderStatusDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderStatusDescPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of OrderStatusDesc objects pre-filled with their OrderStatus objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of OrderStatusDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinOrderStatus(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME);
+ }
+
+ OrderStatusDescPeer::addSelectColumns($criteria);
+ $startcol = OrderStatusDescPeer::NUM_HYDRATE_COLUMNS;
+ OrderStatusPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(OrderStatusDescPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderStatusDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderStatusDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = OrderStatusDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderStatusDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = OrderStatusPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderStatusPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ OrderStatusPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (OrderStatusDesc) to $obj2 (OrderStatus)
+ $obj2->addOrderStatusDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderStatusDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderStatusDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderStatusDescPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of OrderStatusDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of OrderStatusDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME);
+ }
+
+ OrderStatusDescPeer::addSelectColumns($criteria);
+ $startcol2 = OrderStatusDescPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderStatusPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderStatusDescPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderStatusDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderStatusDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = OrderStatusDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderStatusDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined OrderStatus rows
+
+ $key2 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = OrderStatusPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = OrderStatusPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ OrderStatusPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (OrderStatusDesc) to the collection in $obj2 (OrderStatus)
+ $obj2->addOrderStatusDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -630,7 +865,6 @@ abstract class BaseOrderStatusDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += OrderStatusDescPeer::doOnDeleteCascade(new Criteria(OrderStatusDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(OrderStatusDescPeer::TABLE_NAME, $con, OrderStatusDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +898,24 @@ abstract class BaseOrderStatusDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ OrderStatusDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof OrderStatusDesc) { // it's a model object
+ // invalidate the cache for this single object
+ OrderStatusDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(OrderStatusDescPeer::DATABASE_NAME);
$criteria->add(OrderStatusDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ OrderStatusDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,23 +928,6 @@ abstract class BaseOrderStatusDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += OrderStatusDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- OrderStatusDescPeer::clearInstancePool();
- } elseif ($values instanceof OrderStatusDesc) { // it's a model object
- OrderStatusDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- OrderStatusDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
OrderStatusDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -712,39 +939,6 @@ abstract class BaseOrderStatusDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = OrderStatusDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related OrderStatus objects
- $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME);
-
- $criteria->add(OrderStatusPeer::ID, $obj->getStatusId());
- $affectedRows += OrderStatusPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given OrderStatusDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php
index c6a233eeb..5ad88bed4 100644
--- a/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php
@@ -80,7 +80,7 @@ abstract class BaseOrderStatusDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\OrderStatusDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\OrderStatusDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -283,6 +283,8 @@ abstract class BaseOrderStatusDescQuery extends ModelCriteria
* $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12
*
*
+ * @see filterByOrderStatus()
+ *
* @param mixed $statusId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -519,7 +521,7 @@ abstract class BaseOrderStatusDescQuery extends ModelCriteria
/**
* Filter the query by a related OrderStatus object
*
- * @param OrderStatus|PropelObjectCollection $orderStatus the related object to use as filter
+ * @param OrderStatus|PropelObjectCollection $orderStatus The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderStatusDescQuery The current query, for fluid interface
@@ -531,10 +533,12 @@ abstract class BaseOrderStatusDescQuery extends ModelCriteria
return $this
->addUsingAlias(OrderStatusDescPeer::STATUS_ID, $orderStatus->getId(), $comparison);
} elseif ($orderStatus instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useOrderStatusQuery()
- ->filterByPrimaryKeys($orderStatus->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(OrderStatusDescPeer::STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByOrderStatus() only accepts arguments of type OrderStatus or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php b/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php
index 0b5f509f4..27e60e8a1 100644
--- a/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php
@@ -26,7 +26,7 @@ abstract class BaseOrderStatusPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'order_status';
@@ -379,6 +379,12 @@ abstract class BaseOrderStatusPeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in OrderPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderPeer::clearInstancePool();
+ // Invalidate objects in OrderStatusDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderStatusDescPeer::clearInstancePool();
}
/**
@@ -475,639 +481,6 @@ abstract class BaseOrderStatusPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderStatusPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderStatusPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderPeer::STATUS_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related OrderStatusDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinOrderStatusDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderStatusPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderStatusPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderStatusDescPeer::STATUS_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of OrderStatus objects pre-filled with their Order objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderStatus objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
- }
-
- OrderStatusPeer::addSelectColumns($criteria);
- $startcol = OrderStatusPeer::NUM_HYDRATE_COLUMNS;
- OrderPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderPeer::STATUS_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderStatusPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = OrderStatusPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderStatusPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (OrderStatus) to $obj2 (Order)
- // one to one relationship
- $obj1->setOrder($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of OrderStatus objects pre-filled with their OrderStatusDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderStatus objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinOrderStatusDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
- }
-
- OrderStatusPeer::addSelectColumns($criteria);
- $startcol = OrderStatusPeer::NUM_HYDRATE_COLUMNS;
- OrderStatusDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderStatusDescPeer::STATUS_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderStatusPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = OrderStatusPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderStatusPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = OrderStatusDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = OrderStatusDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderStatusDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- OrderStatusDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (OrderStatus) to $obj2 (OrderStatusDesc)
- // one to one relationship
- $obj1->setOrderStatusDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderStatusPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderStatusPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderPeer::STATUS_ID, $join_behavior);
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderStatusDescPeer::STATUS_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of OrderStatus objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderStatus objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
- }
-
- OrderStatusPeer::addSelectColumns($criteria);
- $startcol2 = OrderStatusPeer::NUM_HYDRATE_COLUMNS;
-
- OrderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS;
-
- OrderStatusDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + OrderStatusDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderPeer::STATUS_ID, $join_behavior);
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderStatusDescPeer::STATUS_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderStatusPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = OrderStatusPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderStatusPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Order rows
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (OrderStatus) to the collection in $obj2 (Order)
- $obj1->setOrder($obj2);
- } // if joined row not null
-
- // Add objects for joined OrderStatusDesc rows
-
- $key3 = OrderStatusDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = OrderStatusDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = OrderStatusDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- OrderStatusDescPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (OrderStatus) to the collection in $obj3 (OrderStatusDesc)
- $obj1->setOrderStatusDesc($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Order table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptOrder(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderStatusPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderStatusPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderStatusDescPeer::STATUS_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related OrderStatusDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptOrderStatusDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(OrderStatusPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- OrderStatusPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderPeer::STATUS_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of OrderStatus objects pre-filled with all related objects except Order.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderStatus objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
- }
-
- OrderStatusPeer::addSelectColumns($criteria);
- $startcol2 = OrderStatusPeer::NUM_HYDRATE_COLUMNS;
-
- OrderStatusDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + OrderStatusDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderStatusDescPeer::STATUS_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderStatusPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = OrderStatusPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderStatusPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined OrderStatusDesc rows
-
- $key2 = OrderStatusDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = OrderStatusDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderStatusDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- OrderStatusDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (OrderStatus) to the collection in $obj2 (OrderStatusDesc)
- $obj1->setOrderStatusDesc($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of OrderStatus objects pre-filled with all related objects except OrderStatusDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of OrderStatus objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptOrderStatusDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
- }
-
- OrderStatusPeer::addSelectColumns($criteria);
- $startcol2 = OrderStatusPeer::NUM_HYDRATE_COLUMNS;
-
- OrderPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(OrderStatusPeer::ID, OrderPeer::STATUS_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = OrderStatusPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = OrderStatusPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- OrderStatusPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Order rows
-
- $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = OrderPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = OrderPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- OrderPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (OrderStatus) to the collection in $obj2 (Order)
- $obj1->setOrder($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php
index 184c31d10..9d3a2d1b7 100644
--- a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php
@@ -69,7 +69,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\OrderStatus', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\OrderStatus', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -245,10 +245,6 @@ abstract class BaseOrderStatusQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByOrder()
- *
- * @see filterByOrderStatusDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -384,7 +380,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria
/**
* Filter the query by a related Order object
*
- * @param Order|PropelObjectCollection $order The related object(s) to use as filter
+ * @param Order|PropelObjectCollection $order the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderStatusQuery The current query, for fluid interface
@@ -396,12 +392,10 @@ abstract class BaseOrderStatusQuery extends ModelCriteria
return $this
->addUsingAlias(OrderStatusPeer::ID, $order->getStatusId(), $comparison);
} elseif ($order instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(OrderStatusPeer::ID, $order->toKeyValue('PrimaryKey', 'StatusId'), $comparison);
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
}
@@ -415,7 +409,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria
*
* @return OrderStatusQuery The current query, for fluid interface
*/
- public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Order');
@@ -450,7 +444,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria
*
* @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
*/
- public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinOrder($relationAlias, $joinType)
@@ -460,7 +454,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria
/**
* Filter the query by a related OrderStatusDesc object
*
- * @param OrderStatusDesc|PropelObjectCollection $orderStatusDesc The related object(s) to use as filter
+ * @param OrderStatusDesc|PropelObjectCollection $orderStatusDesc the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return OrderStatusQuery The current query, for fluid interface
@@ -472,12 +466,10 @@ abstract class BaseOrderStatusQuery extends ModelCriteria
return $this
->addUsingAlias(OrderStatusPeer::ID, $orderStatusDesc->getStatusId(), $comparison);
} elseif ($orderStatusDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(OrderStatusPeer::ID, $orderStatusDesc->toKeyValue('PrimaryKey', 'StatusId'), $comparison);
+ ->useOrderStatusDescQuery()
+ ->filterByPrimaryKeys($orderStatusDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByOrderStatusDesc() only accepts arguments of type OrderStatusDesc or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseProduct.php b/core/lib/Thelia/Model/om/BaseProduct.php
index ee068a900..bd38bec51 100644
--- a/core/lib/Thelia/Model/om/BaseProduct.php
+++ b/core/lib/Thelia/Model/om/BaseProduct.php
@@ -156,59 +156,69 @@ abstract class BaseProduct extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Accessory
+ * @var TaxRule
*/
- protected $aAccessory;
+ protected $aTaxRule;
/**
- * @var Accessory
+ * @var PropelObjectCollection|Accessory[] Collection to store aggregation of Accessory objects.
*/
- protected $aAccessory;
+ protected $collAccessorysRelatedByProductId;
+ protected $collAccessorysRelatedByProductIdPartial;
/**
- * @var ContentAssoc
+ * @var PropelObjectCollection|Accessory[] Collection to store aggregation of Accessory objects.
*/
- protected $aContentAssoc;
+ protected $collAccessorysRelatedByAccessory;
+ protected $collAccessorysRelatedByAccessoryPartial;
/**
- * @var Document
+ * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects.
*/
- protected $aDocument;
+ protected $collContentAssocs;
+ protected $collContentAssocsPartial;
/**
- * @var FeatureProd
+ * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects.
*/
- protected $aFeatureProd;
+ protected $collDocuments;
+ protected $collDocumentsPartial;
/**
- * @var Image
+ * @var PropelObjectCollection|FeatureProd[] Collection to store aggregation of FeatureProd objects.
*/
- protected $aImage;
+ protected $collFeatureProds;
+ protected $collFeatureProdsPartial;
/**
- * @var ProductCategory
+ * @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects.
*/
- protected $aProductCategory;
+ protected $collImages;
+ protected $collImagesPartial;
/**
- * @var ProductDesc
+ * @var PropelObjectCollection|ProductCategory[] Collection to store aggregation of ProductCategory objects.
*/
- protected $aProductDesc;
+ protected $collProductCategorys;
+ protected $collProductCategorysPartial;
/**
- * @var Rewriting
+ * @var PropelObjectCollection|ProductDesc[] Collection to store aggregation of ProductDesc objects.
*/
- protected $aRewriting;
+ protected $collProductDescs;
+ protected $collProductDescsPartial;
/**
- * @var Stock
+ * @var PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects.
*/
- protected $aStock;
+ protected $collRewritings;
+ protected $collRewritingsPartial;
/**
- * @var TaxRule one-to-one related TaxRule object
+ * @var PropelObjectCollection|Stock[] Collection to store aggregation of Stock objects.
*/
- protected $singleTaxRule;
+ protected $collStocks;
+ protected $collStocksPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -228,7 +238,61 @@ abstract class BaseProduct extends BaseObject implements Persistent
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
- protected $taxRulesScheduledForDeletion = null;
+ protected $accessorysRelatedByProductIdScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ 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.
@@ -465,46 +529,6 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->modifiedColumns[] = ProductPeer::ID;
}
- if ($this->aAccessory !== null && $this->aAccessory->getProductId() !== $v) {
- $this->aAccessory = null;
- }
-
- if ($this->aAccessory !== null && $this->aAccessory->getAccessory() !== $v) {
- $this->aAccessory = null;
- }
-
- if ($this->aContentAssoc !== null && $this->aContentAssoc->getProductId() !== $v) {
- $this->aContentAssoc = null;
- }
-
- if ($this->aDocument !== null && $this->aDocument->getProductId() !== $v) {
- $this->aDocument = null;
- }
-
- if ($this->aFeatureProd !== null && $this->aFeatureProd->getProductId() !== $v) {
- $this->aFeatureProd = null;
- }
-
- if ($this->aImage !== null && $this->aImage->getProductId() !== $v) {
- $this->aImage = null;
- }
-
- if ($this->aProductCategory !== null && $this->aProductCategory->getProductId() !== $v) {
- $this->aProductCategory = null;
- }
-
- if ($this->aProductDesc !== null && $this->aProductDesc->getProductId() !== $v) {
- $this->aProductDesc = null;
- }
-
- if ($this->aRewriting !== null && $this->aRewriting->getProductId() !== $v) {
- $this->aRewriting = null;
- }
-
- if ($this->aStock !== null && $this->aStock->getProductId() !== $v) {
- $this->aStock = null;
- }
-
return $this;
} // setId()
@@ -526,6 +550,10 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->modifiedColumns[] = ProductPeer::TAX_RULE_ID;
}
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
return $this;
} // setTaxRuleId()
@@ -879,35 +907,8 @@ abstract class BaseProduct extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aAccessory !== null && $this->id !== $this->aAccessory->getProductId()) {
- $this->aAccessory = null;
- }
- if ($this->aAccessory !== null && $this->id !== $this->aAccessory->getAccessory()) {
- $this->aAccessory = null;
- }
- if ($this->aContentAssoc !== null && $this->id !== $this->aContentAssoc->getProductId()) {
- $this->aContentAssoc = null;
- }
- if ($this->aDocument !== null && $this->id !== $this->aDocument->getProductId()) {
- $this->aDocument = null;
- }
- if ($this->aFeatureProd !== null && $this->id !== $this->aFeatureProd->getProductId()) {
- $this->aFeatureProd = null;
- }
- if ($this->aImage !== null && $this->id !== $this->aImage->getProductId()) {
- $this->aImage = null;
- }
- if ($this->aProductCategory !== null && $this->id !== $this->aProductCategory->getProductId()) {
- $this->aProductCategory = null;
- }
- if ($this->aProductDesc !== null && $this->id !== $this->aProductDesc->getProductId()) {
- $this->aProductDesc = null;
- }
- if ($this->aRewriting !== null && $this->id !== $this->aRewriting->getProductId()) {
- $this->aRewriting = null;
- }
- if ($this->aStock !== null && $this->id !== $this->aStock->getProductId()) {
- $this->aStock = null;
+ if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
}
} // ensureConsistency
@@ -948,17 +949,26 @@ abstract class BaseProduct extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aAccessory = null;
- $this->aAccessory = null;
- $this->aContentAssoc = null;
- $this->aDocument = null;
- $this->aFeatureProd = null;
- $this->aImage = null;
- $this->aProductCategory = null;
- $this->aProductDesc = null;
- $this->aRewriting = null;
- $this->aStock = null;
- $this->singleTaxRule = null;
+ $this->aTaxRule = 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)
}
@@ -1078,74 +1088,11 @@ abstract class BaseProduct extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aAccessory !== null) {
- if ($this->aAccessory->isModified() || $this->aAccessory->isNew()) {
- $affectedRows += $this->aAccessory->save($con);
+ if ($this->aTaxRule !== null) {
+ if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
+ $affectedRows += $this->aTaxRule->save($con);
}
- $this->setAccessory($this->aAccessory);
- }
-
- if ($this->aAccessory !== null) {
- if ($this->aAccessory->isModified() || $this->aAccessory->isNew()) {
- $affectedRows += $this->aAccessory->save($con);
- }
- $this->setAccessory($this->aAccessory);
- }
-
- if ($this->aContentAssoc !== null) {
- if ($this->aContentAssoc->isModified() || $this->aContentAssoc->isNew()) {
- $affectedRows += $this->aContentAssoc->save($con);
- }
- $this->setContentAssoc($this->aContentAssoc);
- }
-
- if ($this->aDocument !== null) {
- if ($this->aDocument->isModified() || $this->aDocument->isNew()) {
- $affectedRows += $this->aDocument->save($con);
- }
- $this->setDocument($this->aDocument);
- }
-
- if ($this->aFeatureProd !== null) {
- if ($this->aFeatureProd->isModified() || $this->aFeatureProd->isNew()) {
- $affectedRows += $this->aFeatureProd->save($con);
- }
- $this->setFeatureProd($this->aFeatureProd);
- }
-
- if ($this->aImage !== null) {
- if ($this->aImage->isModified() || $this->aImage->isNew()) {
- $affectedRows += $this->aImage->save($con);
- }
- $this->setImage($this->aImage);
- }
-
- if ($this->aProductCategory !== null) {
- if ($this->aProductCategory->isModified() || $this->aProductCategory->isNew()) {
- $affectedRows += $this->aProductCategory->save($con);
- }
- $this->setProductCategory($this->aProductCategory);
- }
-
- if ($this->aProductDesc !== null) {
- if ($this->aProductDesc->isModified() || $this->aProductDesc->isNew()) {
- $affectedRows += $this->aProductDesc->save($con);
- }
- $this->setProductDesc($this->aProductDesc);
- }
-
- if ($this->aRewriting !== null) {
- if ($this->aRewriting->isModified() || $this->aRewriting->isNew()) {
- $affectedRows += $this->aRewriting->save($con);
- }
- $this->setRewriting($this->aRewriting);
- }
-
- if ($this->aStock !== null) {
- if ($this->aStock->isModified() || $this->aStock->isNew()) {
- $affectedRows += $this->aStock->save($con);
- }
- $this->setStock($this->aStock);
+ $this->setTaxRule($this->aTaxRule);
}
if ($this->isNew() || $this->isModified()) {
@@ -1159,18 +1106,177 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->taxRulesScheduledForDeletion !== null) {
- if (!$this->taxRulesScheduledForDeletion->isEmpty()) {
- TaxRuleQuery::create()
- ->filterByPrimaryKeys($this->taxRulesScheduledForDeletion->getPrimaryKeys(false))
+ if ($this->accessorysRelatedByProductIdScheduledForDeletion !== null) {
+ if (!$this->accessorysRelatedByProductIdScheduledForDeletion->isEmpty()) {
+ AccessoryQuery::create()
+ ->filterByPrimaryKeys($this->accessorysRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
- $this->taxRulesScheduledForDeletion = null;
+ $this->accessorysRelatedByProductIdScheduledForDeletion = null;
}
}
- if ($this->singleTaxRule !== null) {
- if (!$this->singleTaxRule->isDeleted()) {
- $affectedRows += $this->singleTaxRule->save($con);
+ if ($this->collAccessorysRelatedByProductId !== null) {
+ foreach ($this->collAccessorysRelatedByProductId as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->accessorysRelatedByAccessoryScheduledForDeletion !== null) {
+ if (!$this->accessorysRelatedByAccessoryScheduledForDeletion->isEmpty()) {
+ AccessoryQuery::create()
+ ->filterByPrimaryKeys($this->accessorysRelatedByAccessoryScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->accessorysRelatedByAccessoryScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAccessorysRelatedByAccessory !== null) {
+ foreach ($this->collAccessorysRelatedByAccessory 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->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) {
+ // need to save related object because we set the relation to null
+ $rewriting->save($con);
+ }
+ $this->rewritingsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collRewritings !== null) {
+ foreach ($this->collRewritings 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);
+ }
}
}
@@ -1394,63 +1500,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aAccessory !== null) {
- if (!$this->aAccessory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAccessory->getValidationFailures());
- }
- }
-
- if ($this->aAccessory !== null) {
- if (!$this->aAccessory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aAccessory->getValidationFailures());
- }
- }
-
- if ($this->aContentAssoc !== null) {
- if (!$this->aContentAssoc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aContentAssoc->getValidationFailures());
- }
- }
-
- if ($this->aDocument !== null) {
- if (!$this->aDocument->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aDocument->getValidationFailures());
- }
- }
-
- if ($this->aFeatureProd !== null) {
- if (!$this->aFeatureProd->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aFeatureProd->getValidationFailures());
- }
- }
-
- if ($this->aImage !== null) {
- if (!$this->aImage->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aImage->getValidationFailures());
- }
- }
-
- if ($this->aProductCategory !== null) {
- if (!$this->aProductCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aProductCategory->getValidationFailures());
- }
- }
-
- if ($this->aProductDesc !== null) {
- if (!$this->aProductDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aProductDesc->getValidationFailures());
- }
- }
-
- if ($this->aRewriting !== null) {
- if (!$this->aRewriting->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aRewriting->getValidationFailures());
- }
- }
-
- if ($this->aStock !== null) {
- if (!$this->aStock->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aStock->getValidationFailures());
+ if ($this->aTaxRule !== null) {
+ if (!$this->aTaxRule->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures());
}
}
@@ -1460,9 +1512,83 @@ abstract class BaseProduct extends BaseObject implements Persistent
}
- if ($this->singleTaxRule !== null) {
- if (!$this->singleTaxRule->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleTaxRule->getValidationFailures());
+ if ($this->collAccessorysRelatedByProductId !== null) {
+ foreach ($this->collAccessorysRelatedByProductId as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collAccessorysRelatedByAccessory !== null) {
+ foreach ($this->collAccessorysRelatedByAccessory 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->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)) {
+ $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());
+ }
}
}
@@ -1588,38 +1714,38 @@ abstract class BaseProduct extends BaseObject implements Persistent
$keys[13] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aAccessory) {
- $result['Accessory'] = $this->aAccessory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->aAccessory) {
- $result['Accessory'] = $this->aAccessory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAccessorysRelatedByProductId) {
+ $result['AccessorysRelatedByProductId'] = $this->collAccessorysRelatedByProductId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aContentAssoc) {
- $result['ContentAssoc'] = $this->aContentAssoc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collAccessorysRelatedByAccessory) {
+ $result['AccessorysRelatedByAccessory'] = $this->collAccessorysRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aDocument) {
- $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aFeatureProd) {
- $result['FeatureProd'] = $this->aFeatureProd->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aImage) {
- $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aProductCategory) {
- $result['ProductCategory'] = $this->aProductCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aProductDesc) {
- $result['ProductDesc'] = $this->aProductDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collProductCategorys) {
+ $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aRewriting) {
- $result['Rewriting'] = $this->aRewriting->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collProductDescs) {
+ $result['ProductDescs'] = $this->collProductDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aStock) {
- $result['Stock'] = $this->aStock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->singleTaxRule) {
- $result['TaxRule'] = $this->singleTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collStocks) {
+ $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1844,59 +1970,64 @@ abstract class BaseProduct extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getTaxRule();
- if ($relObj) {
- $copyObj->setTaxRule($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));
+ }
}
- $relObj = $this->getAccessory();
- if ($relObj) {
- $copyObj->setAccessory($relObj->copy($deepCopy));
+ foreach ($this->getAccessorysRelatedByAccessory() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAccessoryRelatedByAccessory($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getAccessory();
- if ($relObj) {
- $copyObj->setAccessory($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));
+ }
}
- $relObj = $this->getContentAssoc();
- if ($relObj) {
- $copyObj->setContentAssoc($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));
+ }
}
- $relObj = $this->getDocument();
- if ($relObj) {
- $copyObj->setDocument($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));
+ }
}
- $relObj = $this->getFeatureProd();
- if ($relObj) {
- $copyObj->setFeatureProd($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));
+ }
}
- $relObj = $this->getImage();
- if ($relObj) {
- $copyObj->setImage($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));
+ }
}
- $relObj = $this->getProductCategory();
- if ($relObj) {
- $copyObj->setProductCategory($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));
+ }
}
- $relObj = $this->getProductDesc();
- if ($relObj) {
- $copyObj->setProductDesc($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));
+ }
}
- $relObj = $this->getRewriting();
- if ($relObj) {
- $copyObj->setRewriting($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getStock();
- if ($relObj) {
- $copyObj->setStock($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
@@ -1950,25 +2081,26 @@ abstract class BaseProduct extends BaseObject implements Persistent
}
/**
- * Declares an association between this object and a Accessory object.
+ * Declares an association between this object and a TaxRule object.
*
- * @param Accessory $v
+ * @param TaxRule $v
* @return Product The current object (for fluent API support)
* @throws PropelException
*/
- public function setAccessory(Accessory $v = null)
+ public function setTaxRule(TaxRule $v = null)
{
if ($v === null) {
- $this->setId(NULL);
+ $this->setTaxRuleId(NULL);
} else {
- $this->setId($v->getProductId());
+ $this->setTaxRuleId($v->getId());
}
- $this->aAccessory = $v;
+ $this->aTaxRule = $v;
- // Add binding for other direction of this 1:1 relationship.
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the TaxRule object, it will not be re-added.
if ($v !== null) {
- $v->setProduct($this);
+ $v->addProduct($this);
}
@@ -1977,446 +2109,26 @@ abstract class BaseProduct extends BaseObject implements Persistent
/**
- * Get the associated Accessory object
+ * Get the associated TaxRule object
*
* @param PropelPDO $con Optional Connection object.
- * @return Accessory The associated Accessory object.
+ * @return TaxRule The associated TaxRule object.
* @throws PropelException
*/
- public function getAccessory(PropelPDO $con = null)
+ public function getTaxRule(PropelPDO $con = null)
{
- if ($this->aAccessory === null && ($this->id !== null)) {
- $this->aAccessory = AccessoryQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAccessory->setProduct($this);
+ if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) {
+ $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_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->aTaxRule->addProducts($this);
+ */
}
- return $this->aAccessory;
- }
-
- /**
- * Declares an association between this object and a Accessory object.
- *
- * @param Accessory $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setAccessory(Accessory $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getAccessory());
- }
-
- $this->aAccessory = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated Accessory object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Accessory The associated Accessory object.
- * @throws PropelException
- */
- public function getAccessory(PropelPDO $con = null)
- {
- if ($this->aAccessory === null && ($this->id !== null)) {
- $this->aAccessory = AccessoryQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aAccessory->setProduct($this);
- }
-
- return $this->aAccessory;
- }
-
- /**
- * Declares an association between this object and a ContentAssoc object.
- *
- * @param ContentAssoc $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setContentAssoc(ContentAssoc $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getProductId());
- }
-
- $this->aContentAssoc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated ContentAssoc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ContentAssoc The associated ContentAssoc object.
- * @throws PropelException
- */
- public function getContentAssoc(PropelPDO $con = null)
- {
- if ($this->aContentAssoc === null && ($this->id !== null)) {
- $this->aContentAssoc = ContentAssocQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aContentAssoc->setProduct($this);
- }
-
- return $this->aContentAssoc;
- }
-
- /**
- * Declares an association between this object and a Document object.
- *
- * @param Document $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setDocument(Document $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getProductId());
- }
-
- $this->aDocument = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated Document object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Document The associated Document object.
- * @throws PropelException
- */
- public function getDocument(PropelPDO $con = null)
- {
- if ($this->aDocument === null && ($this->id !== null)) {
- $this->aDocument = DocumentQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aDocument->setProduct($this);
- }
-
- return $this->aDocument;
- }
-
- /**
- * Declares an association between this object and a FeatureProd object.
- *
- * @param FeatureProd $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setFeatureProd(FeatureProd $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getProductId());
- }
-
- $this->aFeatureProd = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated FeatureProd object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return FeatureProd The associated FeatureProd object.
- * @throws PropelException
- */
- public function getFeatureProd(PropelPDO $con = null)
- {
- if ($this->aFeatureProd === null && ($this->id !== null)) {
- $this->aFeatureProd = FeatureProdQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aFeatureProd->setProduct($this);
- }
-
- return $this->aFeatureProd;
- }
-
- /**
- * Declares an association between this object and a Image object.
- *
- * @param Image $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setImage(Image $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getProductId());
- }
-
- $this->aImage = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated Image object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Image The associated Image object.
- * @throws PropelException
- */
- public function getImage(PropelPDO $con = null)
- {
- if ($this->aImage === null && ($this->id !== null)) {
- $this->aImage = ImageQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aImage->setProduct($this);
- }
-
- return $this->aImage;
- }
-
- /**
- * Declares an association between this object and a ProductCategory object.
- *
- * @param ProductCategory $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setProductCategory(ProductCategory $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getProductId());
- }
-
- $this->aProductCategory = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated ProductCategory object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ProductCategory The associated ProductCategory object.
- * @throws PropelException
- */
- public function getProductCategory(PropelPDO $con = null)
- {
- if ($this->aProductCategory === null && ($this->id !== null)) {
- $this->aProductCategory = ProductCategoryQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aProductCategory->setProduct($this);
- }
-
- return $this->aProductCategory;
- }
-
- /**
- * Declares an association between this object and a ProductDesc object.
- *
- * @param ProductDesc $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setProductDesc(ProductDesc $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getProductId());
- }
-
- $this->aProductDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated ProductDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ProductDesc The associated ProductDesc object.
- * @throws PropelException
- */
- public function getProductDesc(PropelPDO $con = null)
- {
- if ($this->aProductDesc === null && ($this->id !== null)) {
- $this->aProductDesc = ProductDescQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aProductDesc->setProduct($this);
- }
-
- return $this->aProductDesc;
- }
-
- /**
- * Declares an association between this object and a Rewriting object.
- *
- * @param Rewriting $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setRewriting(Rewriting $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getProductId());
- }
-
- $this->aRewriting = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated Rewriting object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Rewriting The associated Rewriting object.
- * @throws PropelException
- */
- public function getRewriting(PropelPDO $con = null)
- {
- if ($this->aRewriting === null && ($this->id !== null)) {
- $this->aRewriting = RewritingQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aRewriting->setProduct($this);
- }
-
- return $this->aRewriting;
- }
-
- /**
- * Declares an association between this object and a Stock object.
- *
- * @param Stock $v
- * @return Product The current object (for fluent API support)
- * @throws PropelException
- */
- public function setStock(Stock $v = null)
- {
- if ($v === null) {
- $this->setId(NULL);
- } else {
- $this->setId($v->getProductId());
- }
-
- $this->aStock = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setProduct($this);
- }
-
-
- return $this;
- }
-
-
- /**
- * Get the associated Stock object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Stock The associated Stock object.
- * @throws PropelException
- */
- public function getStock(PropelPDO $con = null)
- {
- if ($this->aStock === null && ($this->id !== null)) {
- $this->aStock = StockQuery::create()
- ->filterByProduct($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aStock->setProduct($this);
- }
-
- return $this->aStock;
+ return $this->aTaxRule;
}
@@ -2430,44 +2142,2483 @@ abstract class BaseProduct extends BaseObject implements Persistent
*/
public function initRelation($relationName)
{
+ 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();
+ }
}
/**
- * Gets a single TaxRule object, which is related to this object by a one-to-one relationship.
+ * Clears out the collAccessorysRelatedByProductId 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 addAccessorysRelatedByProductId()
+ */
+ public function clearAccessorysRelatedByProductId()
+ {
+ $this->collAccessorysRelatedByProductId = null; // important to set this to null since that means it is uninitialized
+ $this->collAccessorysRelatedByProductIdPartial = null;
+ }
+
+ /**
+ * reset is the collAccessorysRelatedByProductId collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAccessorysRelatedByProductId($v = true)
+ {
+ $this->collAccessorysRelatedByProductIdPartial = $v;
+ }
+
+ /**
+ * Initializes the collAccessorysRelatedByProductId collection.
+ *
+ * By default this just sets the collAccessorysRelatedByProductId collection to an empty array (like clearcollAccessorysRelatedByProductId());
+ * 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 initAccessorysRelatedByProductId($overrideExisting = true)
+ {
+ if (null !== $this->collAccessorysRelatedByProductId && !$overrideExisting) {
+ return;
+ }
+ $this->collAccessorysRelatedByProductId = new PropelObjectCollection();
+ $this->collAccessorysRelatedByProductId->setModel('Accessory');
+ }
+
+ /**
+ * Gets an array of Accessory 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 TaxRule
+ * @return PropelObjectCollection|Accessory[] List of Accessory objects
* @throws PropelException
*/
- public function getTaxRule(PropelPDO $con = null)
+ public function getAccessorysRelatedByProductId($criteria = null, PropelPDO $con = null)
{
+ $partial = $this->collAccessorysRelatedByProductIdPartial && !$this->isNew();
+ if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) {
+ // return empty collection
+ $this->initAccessorysRelatedByProductId();
+ } else {
+ $collAccessorysRelatedByProductId = AccessoryQuery::create(null, $criteria)
+ ->filterByProductRelatedByProductId($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAccessorysRelatedByProductIdPartial && count($collAccessorysRelatedByProductId)) {
+ $this->initAccessorysRelatedByProductId(false);
- if ($this->singleTaxRule === null && !$this->isNew()) {
- $this->singleTaxRule = TaxRuleQuery::create()->findPk($this->getPrimaryKey(), $con);
+ foreach($collAccessorysRelatedByProductId as $obj) {
+ if (false == $this->collAccessorysRelatedByProductId->contains($obj)) {
+ $this->collAccessorysRelatedByProductId->append($obj);
+ }
+ }
+
+ $this->collAccessorysRelatedByProductIdPartial = true;
+ }
+
+ return $collAccessorysRelatedByProductId;
+ }
+
+ if($partial && $this->collAccessorysRelatedByProductId) {
+ foreach($this->collAccessorysRelatedByProductId as $obj) {
+ if($obj->isNew()) {
+ $collAccessorysRelatedByProductId[] = $obj;
+ }
+ }
+ }
+
+ $this->collAccessorysRelatedByProductId = $collAccessorysRelatedByProductId;
+ $this->collAccessorysRelatedByProductIdPartial = false;
+ }
}
- return $this->singleTaxRule;
+ return $this->collAccessorysRelatedByProductId;
}
/**
- * Sets a single TaxRule object as related to this object by a one-to-one relationship.
+ * Sets a collection of AccessoryRelatedByProductId 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 TaxRule $v TaxRule
- * @return Product The current object (for fluent API support)
+ * @param PropelCollection $accessorysRelatedByProductId A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAccessorysRelatedByProductId(PropelCollection $accessorysRelatedByProductId, PropelPDO $con = null)
+ {
+ $this->accessorysRelatedByProductIdScheduledForDeletion = $this->getAccessorysRelatedByProductId(new Criteria(), $con)->diff($accessorysRelatedByProductId);
+
+ foreach ($this->accessorysRelatedByProductIdScheduledForDeletion as $accessoryRelatedByProductIdRemoved) {
+ $accessoryRelatedByProductIdRemoved->setProductRelatedByProductId(null);
+ }
+
+ $this->collAccessorysRelatedByProductId = null;
+ foreach ($accessorysRelatedByProductId as $accessoryRelatedByProductId) {
+ $this->addAccessoryRelatedByProductId($accessoryRelatedByProductId);
+ }
+
+ $this->collAccessorysRelatedByProductId = $accessorysRelatedByProductId;
+ $this->collAccessorysRelatedByProductIdPartial = false;
+ }
+
+ /**
+ * Returns the number of related Accessory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Accessory objects.
* @throws PropelException
*/
- public function setTaxRule(TaxRule $v = null)
+ public function countAccessorysRelatedByProductId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
- $this->singleTaxRule = $v;
+ $partial = $this->collAccessorysRelatedByProductIdPartial && !$this->isNew();
+ if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAccessorysRelatedByProductId());
+ }
+ $query = AccessoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
- // Make sure that that the passed-in TaxRule isn't already associated with this object
- if ($v !== null && $v->getProduct() === null) {
- $v->setProduct($this);
+ return $query
+ ->filterByProductRelatedByProductId($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAccessorysRelatedByProductId);
+ }
+ }
+
+ /**
+ * Method called to associate a Accessory object to this object
+ * through the Accessory foreign key attribute.
+ *
+ * @param Accessory $l Accessory
+ * @return Product The current object (for fluent API support)
+ */
+ public function addAccessoryRelatedByProductId(Accessory $l)
+ {
+ if ($this->collAccessorysRelatedByProductId === null) {
+ $this->initAccessorysRelatedByProductId();
+ $this->collAccessorysRelatedByProductIdPartial = true;
+ }
+ if (!$this->collAccessorysRelatedByProductId->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAccessoryRelatedByProductId($l);
}
return $this;
}
+ /**
+ * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to add.
+ */
+ protected function doAddAccessoryRelatedByProductId($accessoryRelatedByProductId)
+ {
+ $this->collAccessorysRelatedByProductId[]= $accessoryRelatedByProductId;
+ $accessoryRelatedByProductId->setProductRelatedByProductId($this);
+ }
+
+ /**
+ * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to remove.
+ */
+ public function removeAccessoryRelatedByProductId($accessoryRelatedByProductId)
+ {
+ if ($this->getAccessorysRelatedByProductId()->contains($accessoryRelatedByProductId)) {
+ $this->collAccessorysRelatedByProductId->remove($this->collAccessorysRelatedByProductId->search($accessoryRelatedByProductId));
+ if (null === $this->accessorysRelatedByProductIdScheduledForDeletion) {
+ $this->accessorysRelatedByProductIdScheduledForDeletion = clone $this->collAccessorysRelatedByProductId;
+ $this->accessorysRelatedByProductIdScheduledForDeletion->clear();
+ }
+ $this->accessorysRelatedByProductIdScheduledForDeletion[]= $accessoryRelatedByProductId;
+ $accessoryRelatedByProductId->setProductRelatedByProductId(null);
+ }
+ }
+
+ /**
+ * Clears out the collAccessorysRelatedByAccessory 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 addAccessorysRelatedByAccessory()
+ */
+ public function clearAccessorysRelatedByAccessory()
+ {
+ $this->collAccessorysRelatedByAccessory = null; // important to set this to null since that means it is uninitialized
+ $this->collAccessorysRelatedByAccessoryPartial = null;
+ }
+
+ /**
+ * reset is the collAccessorysRelatedByAccessory collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAccessorysRelatedByAccessory($v = true)
+ {
+ $this->collAccessorysRelatedByAccessoryPartial = $v;
+ }
+
+ /**
+ * Initializes the collAccessorysRelatedByAccessory collection.
+ *
+ * By default this just sets the collAccessorysRelatedByAccessory collection to an empty array (like clearcollAccessorysRelatedByAccessory());
+ * 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 initAccessorysRelatedByAccessory($overrideExisting = true)
+ {
+ if (null !== $this->collAccessorysRelatedByAccessory && !$overrideExisting) {
+ return;
+ }
+ $this->collAccessorysRelatedByAccessory = new PropelObjectCollection();
+ $this->collAccessorysRelatedByAccessory->setModel('Accessory');
+ }
+
+ /**
+ * Gets an array of Accessory 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|Accessory[] List of Accessory objects
+ * @throws PropelException
+ */
+ public function getAccessorysRelatedByAccessory($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collAccessorysRelatedByAccessoryPartial && !$this->isNew();
+ if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) {
+ // return empty collection
+ $this->initAccessorysRelatedByAccessory();
+ } else {
+ $collAccessorysRelatedByAccessory = AccessoryQuery::create(null, $criteria)
+ ->filterByProductRelatedByAccessory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAccessorysRelatedByAccessoryPartial && count($collAccessorysRelatedByAccessory)) {
+ $this->initAccessorysRelatedByAccessory(false);
+
+ foreach($collAccessorysRelatedByAccessory as $obj) {
+ if (false == $this->collAccessorysRelatedByAccessory->contains($obj)) {
+ $this->collAccessorysRelatedByAccessory->append($obj);
+ }
+ }
+
+ $this->collAccessorysRelatedByAccessoryPartial = true;
+ }
+
+ return $collAccessorysRelatedByAccessory;
+ }
+
+ if($partial && $this->collAccessorysRelatedByAccessory) {
+ foreach($this->collAccessorysRelatedByAccessory as $obj) {
+ if($obj->isNew()) {
+ $collAccessorysRelatedByAccessory[] = $obj;
+ }
+ }
+ }
+
+ $this->collAccessorysRelatedByAccessory = $collAccessorysRelatedByAccessory;
+ $this->collAccessorysRelatedByAccessoryPartial = false;
+ }
+ }
+
+ return $this->collAccessorysRelatedByAccessory;
+ }
+
+ /**
+ * Sets a collection of AccessoryRelatedByAccessory 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 $accessorysRelatedByAccessory A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAccessorysRelatedByAccessory(PropelCollection $accessorysRelatedByAccessory, PropelPDO $con = null)
+ {
+ $this->accessorysRelatedByAccessoryScheduledForDeletion = $this->getAccessorysRelatedByAccessory(new Criteria(), $con)->diff($accessorysRelatedByAccessory);
+
+ foreach ($this->accessorysRelatedByAccessoryScheduledForDeletion as $accessoryRelatedByAccessoryRemoved) {
+ $accessoryRelatedByAccessoryRemoved->setProductRelatedByAccessory(null);
+ }
+
+ $this->collAccessorysRelatedByAccessory = null;
+ foreach ($accessorysRelatedByAccessory as $accessoryRelatedByAccessory) {
+ $this->addAccessoryRelatedByAccessory($accessoryRelatedByAccessory);
+ }
+
+ $this->collAccessorysRelatedByAccessory = $accessorysRelatedByAccessory;
+ $this->collAccessorysRelatedByAccessoryPartial = false;
+ }
+
+ /**
+ * Returns the number of related Accessory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Accessory objects.
+ * @throws PropelException
+ */
+ public function countAccessorysRelatedByAccessory(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAccessorysRelatedByAccessoryPartial && !$this->isNew();
+ if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAccessorysRelatedByAccessory());
+ }
+ $query = AccessoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProductRelatedByAccessory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAccessorysRelatedByAccessory);
+ }
+ }
+
+ /**
+ * Method called to associate a Accessory object to this object
+ * through the Accessory foreign key attribute.
+ *
+ * @param Accessory $l Accessory
+ * @return Product The current object (for fluent API support)
+ */
+ public function addAccessoryRelatedByAccessory(Accessory $l)
+ {
+ if ($this->collAccessorysRelatedByAccessory === null) {
+ $this->initAccessorysRelatedByAccessory();
+ $this->collAccessorysRelatedByAccessoryPartial = true;
+ }
+ if (!$this->collAccessorysRelatedByAccessory->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAccessoryRelatedByAccessory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to add.
+ */
+ protected function doAddAccessoryRelatedByAccessory($accessoryRelatedByAccessory)
+ {
+ $this->collAccessorysRelatedByAccessory[]= $accessoryRelatedByAccessory;
+ $accessoryRelatedByAccessory->setProductRelatedByAccessory($this);
+ }
+
+ /**
+ * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to remove.
+ */
+ public function removeAccessoryRelatedByAccessory($accessoryRelatedByAccessory)
+ {
+ if ($this->getAccessorysRelatedByAccessory()->contains($accessoryRelatedByAccessory)) {
+ $this->collAccessorysRelatedByAccessory->remove($this->collAccessorysRelatedByAccessory->search($accessoryRelatedByAccessory));
+ if (null === $this->accessorysRelatedByAccessoryScheduledForDeletion) {
+ $this->accessorysRelatedByAccessoryScheduledForDeletion = clone $this->collAccessorysRelatedByAccessory;
+ $this->accessorysRelatedByAccessoryScheduledForDeletion->clear();
+ }
+ $this->accessorysRelatedByAccessoryScheduledForDeletion[]= $accessoryRelatedByAccessory;
+ $accessoryRelatedByAccessory->setProductRelatedByAccessory(null);
+ }
+ }
+
+ /**
+ * 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
+ *
+ * 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 addRewritings()
+ */
+ public function clearRewritings()
+ {
+ $this->collRewritings = null; // important to set this to null since that means it is uninitialized
+ $this->collRewritingsPartial = null;
+ }
+
+ /**
+ * reset is the collRewritings collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialRewritings($v = true)
+ {
+ $this->collRewritingsPartial = $v;
+ }
+
+ /**
+ * Initializes the collRewritings collection.
+ *
+ * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
+ * 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 initRewritings($overrideExisting = true)
+ {
+ if (null !== $this->collRewritings && !$overrideExisting) {
+ return;
+ }
+ $this->collRewritings = new PropelObjectCollection();
+ $this->collRewritings->setModel('Rewriting');
+ }
+
+ /**
+ * Gets an array of Rewriting 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|Rewriting[] List of Rewriting objects
+ * @throws PropelException
+ */
+ public function getRewritings($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ // return empty collection
+ $this->initRewritings();
+ } else {
+ $collRewritings = RewritingQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collRewritingsPartial && count($collRewritings)) {
+ $this->initRewritings(false);
+
+ foreach($collRewritings as $obj) {
+ if (false == $this->collRewritings->contains($obj)) {
+ $this->collRewritings->append($obj);
+ }
+ }
+
+ $this->collRewritingsPartial = true;
+ }
+
+ return $collRewritings;
+ }
+
+ if($partial && $this->collRewritings) {
+ foreach($this->collRewritings as $obj) {
+ if($obj->isNew()) {
+ $collRewritings[] = $obj;
+ }
+ }
+ }
+
+ $this->collRewritings = $collRewritings;
+ $this->collRewritingsPartial = false;
+ }
+ }
+
+ return $this->collRewritings;
+ }
+
+ /**
+ * Sets a collection of Rewriting 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 $rewritings A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
+ {
+ $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
+
+ foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) {
+ $rewritingRemoved->setProduct(null);
+ }
+
+ $this->collRewritings = null;
+ foreach ($rewritings as $rewriting) {
+ $this->addRewriting($rewriting);
+ }
+
+ $this->collRewritings = $rewritings;
+ $this->collRewritingsPartial = false;
+ }
+
+ /**
+ * Returns the number of related Rewriting objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Rewriting objects.
+ * @throws PropelException
+ */
+ public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getRewritings());
+ }
+ $query = RewritingQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collRewritings);
+ }
+ }
+
+ /**
+ * Method called to associate a Rewriting object to this object
+ * through the Rewriting foreign key attribute.
+ *
+ * @param Rewriting $l Rewriting
+ * @return Product The current object (for fluent API support)
+ */
+ public function addRewriting(Rewriting $l)
+ {
+ if ($this->collRewritings === null) {
+ $this->initRewritings();
+ $this->collRewritingsPartial = true;
+ }
+ if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddRewriting($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to add.
+ */
+ protected function doAddRewriting($rewriting)
+ {
+ $this->collRewritings[]= $rewriting;
+ $rewriting->setProduct($this);
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to remove.
+ */
+ public function removeRewriting($rewriting)
+ {
+ if ($this->getRewritings()->contains($rewriting)) {
+ $this->collRewritings->remove($this->collRewritings->search($rewriting));
+ if (null === $this->rewritingsScheduledForDeletion) {
+ $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
+ $this->rewritingsScheduledForDeletion->clear();
+ }
+ $this->rewritingsScheduledForDeletion[]= $rewriting;
+ $rewriting->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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Category', $join_behavior);
+
+ return $this->getRewritings($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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Folder', $join_behavior);
+
+ return $this->getRewritings($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 Rewritings 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|Rewriting[] List of Rewriting objects
+ */
+ public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = RewritingQuery::create(null, $criteria);
+ $query->joinWith('Content', $join_behavior);
+
+ 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
*/
@@ -2508,25 +4659,99 @@ abstract class BaseProduct extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleTaxRule) {
- $this->singleTaxRule->clearAllReferences($deep);
+ if ($this->collAccessorysRelatedByProductId) {
+ foreach ($this->collAccessorysRelatedByProductId as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAccessorysRelatedByAccessory) {
+ foreach ($this->collAccessorysRelatedByAccessory as $o) {
+ $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->singleTaxRule instanceof PropelCollection) {
- $this->singleTaxRule->clearIterator();
+ if ($this->collAccessorysRelatedByProductId instanceof PropelCollection) {
+ $this->collAccessorysRelatedByProductId->clearIterator();
}
- $this->singleTaxRule = null;
- $this->aAccessory = null;
- $this->aAccessory = null;
- $this->aContentAssoc = null;
- $this->aDocument = null;
- $this->aFeatureProd = null;
- $this->aImage = null;
- $this->aProductCategory = null;
- $this->aProductDesc = null;
- $this->aRewriting = null;
- $this->aStock = null;
+ $this->collAccessorysRelatedByProductId = null;
+ if ($this->collAccessorysRelatedByAccessory instanceof PropelCollection) {
+ $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;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseProductCategory.php b/core/lib/Thelia/Model/om/BaseProductCategory.php
index ca72906ef..8814b09b1 100644
--- a/core/lib/Thelia/Model/om/BaseProductCategory.php
+++ b/core/lib/Thelia/Model/om/BaseProductCategory.php
@@ -9,9 +9,7 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Category;
use Thelia\Model\CategoryQuery;
@@ -62,14 +60,14 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
protected $category_id;
/**
- * @var Category one-to-one related Category object
+ * @var Product
*/
- protected $singleCategory;
+ protected $aProduct;
/**
- * @var Product one-to-one related Product object
+ * @var Category
*/
- protected $singleProduct;
+ protected $aCategory;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -85,18 +83,6 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $categorysScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
-
/**
* Get the [product_id] column value.
*
@@ -134,6 +120,10 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
$this->modifiedColumns[] = ProductCategoryPeer::PRODUCT_ID;
}
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
return $this;
} // setProductId()
@@ -155,6 +145,10 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
$this->modifiedColumns[] = ProductCategoryPeer::CATEGORY_ID;
}
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
return $this;
} // setCategoryId()
@@ -224,6 +218,12 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
} // ensureConsistency
/**
@@ -263,10 +263,8 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCategory = null;
-
- $this->singleProduct = null;
-
+ $this->aProduct = null;
+ $this->aCategory = null;
} // if (deep)
}
@@ -380,6 +378,25 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -391,36 +408,6 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->categorysScheduledForDeletion !== null) {
- if (!$this->categorysScheduledForDeletion->isEmpty()) {
- CategoryQuery::create()
- ->filterByPrimaryKeys($this->categorysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->categorysScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->isDeleted()) {
- $affectedRows += $this->singleCategory->save($con);
- }
- }
-
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -553,23 +540,29 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if (!$this->aProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
+ }
+ }
+
+ if ($this->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+
if (($retval = ProductCategoryPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCategory->getValidationFailures());
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -644,11 +637,11 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
$keys[1] => $this->getCategoryId(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCategory) {
- $result['Category'] = $this->singleCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -809,16 +802,6 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCategory();
- if ($relObj) {
- $copyObj->setCategory($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -868,91 +851,108 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Product object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Category object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Category
- * @throws PropelException
- */
- public function getCategory(PropelPDO $con = null)
- {
-
- if ($this->singleCategory === null && !$this->isNew()) {
- $this->singleCategory = CategoryQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCategory;
- }
-
- /**
- * Sets a single Category object as related to this object by a one-to-one relationship.
- *
- * @param Category $v Category
- * @return ProductCategory The current object (for fluent API support)
- * @throws PropelException
- */
- public function setCategory(Category $v = null)
- {
- $this->singleCategory = $v;
-
- // Make sure that that the passed-in Category isn't already associated with this object
- if ($v !== null && $v->getProductCategory() === null) {
- $v->setProductCategory($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Product
- * @throws PropelException
- */
- public function getProduct(PropelPDO $con = null)
- {
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleProduct;
- }
-
- /**
- * Sets a single Product object as related to this object by a one-to-one relationship.
- *
- * @param Product $v Product
+ * @param Product $v
* @return ProductCategory The current object (for fluent API support)
* @throws PropelException
*/
public function setProduct(Product $v = null)
{
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getProductCategory() === null) {
- $v->setProductCategory($this);
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
}
+ $this->aProduct = $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 ($v !== null) {
+ $v->addProductCategory($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Product object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
+ * @throws PropelException
+ */
+ public function getProduct(PropelPDO $con = null)
+ {
+ 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->aProduct->addProductCategorys($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return ProductCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(Category $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Category object, it will not be re-added.
+ if ($v !== null) {
+ $v->addProductCategory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Category object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Category The associated Category object.
+ * @throws PropelException
+ */
+ public function getCategory(PropelPDO $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->category_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->aCategory->addProductCategorys($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -980,22 +980,10 @@ abstract class BaseProductCategory extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCategory) {
- $this->singleCategory->clearAllReferences($deep);
- }
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCategory instanceof PropelCollection) {
- $this->singleCategory->clearIterator();
- }
- $this->singleCategory = null;
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php
index 5f5b0c51c..e3a614cee 100644
--- a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php
+++ b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php
@@ -26,7 +26,7 @@ abstract class BaseProductCategoryPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'product_category';
@@ -369,12 +369,6 @@ abstract class BaseProductCategoryPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CategoryPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CategoryPeer::clearInstancePool();
- // Invalidate objects in ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
}
/**
@@ -471,6 +465,637 @@ abstract class BaseProductCategoryPeer
return array($obj, $col);
}
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ProductCategory 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
+ * @return array Array of ProductCategory objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+ }
+
+ ProductCategoryPeer::addSelectColumns($criteria);
+ $startcol = ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ProductCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ProductCategory) to $obj2 (Product)
+ $obj2->addProductCategory($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of ProductCategory objects pre-filled with their Category objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ProductCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+ }
+
+ ProductCategoryPeer::addSelectColumns($criteria);
+ $startcol = ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ProductCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ProductCategory) to $obj2 (Category)
+ $obj2->addProductCategory($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ProductCategory objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ProductCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+ }
+
+ ProductCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ProductCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ProductCategory) to the collection in $obj2 (Product)
+ $obj2->addProductCategory($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (ProductCategory) to the collection in $obj3 (Category)
+ $obj3->addProductCategory($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductCategoryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ProductCategory objects pre-filled with all related objects except Product.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ProductCategory objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+ }
+
+ ProductCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ProductCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (ProductCategory) to the collection in $obj2 (Category)
+ $obj2->addProductCategory($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of ProductCategory objects pre-filled with all related objects except Category.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ProductCategory objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+ }
+
+ ProductCategoryPeer::addSelectColumns($criteria);
+ $startcol2 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ProductCategoryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductCategoryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (ProductCategory) to the collection in $obj2 (Product)
+ $obj2->addProductCategory($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -608,7 +1233,6 @@ abstract class BaseProductCategoryPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ProductCategoryPeer::doOnDeleteCascade(new Criteria(ProductCategoryPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ProductCategoryPeer::TABLE_NAME, $con, ProductCategoryPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -642,9 +1266,15 @@ abstract class BaseProductCategoryPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ProductCategoryPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ProductCategory) { // it's a model object
+ // invalidate the cache for this single object
+ ProductCategoryPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
@@ -659,6 +1289,8 @@ abstract class BaseProductCategoryPeer
$criterion = $criteria->getNewCriterion(ProductCategoryPeer::PRODUCT_ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(ProductCategoryPeer::CATEGORY_ID, $value[1]));
$criteria->addOr($criterion);
+ // we can invalidate the cache for this single PK
+ ProductCategoryPeer::removeInstanceFromPool($value);
}
}
@@ -672,23 +1304,6 @@ abstract class BaseProductCategoryPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ProductCategoryPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ProductCategoryPeer::clearInstancePool();
- } elseif ($values instanceof ProductCategory) { // it's a model object
- ProductCategoryPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ProductCategoryPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ProductCategoryPeer::clearRelatedInstancePool();
$con->commit();
@@ -700,45 +1315,6 @@ abstract class BaseProductCategoryPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ProductCategoryPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Category objects
- $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
-
- $criteria->add(CategoryPeer::ID, $obj->getCategoryId());
- $affectedRows += CategoryPeer::doDelete($criteria, $con);
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ProductCategory object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php
index f3d5c48e2..13124bde2 100644
--- a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php
+++ b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php
@@ -33,14 +33,14 @@ use Thelia\Model\ProductCategoryQuery;
* @method ProductCategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ProductCategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method ProductCategoryQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
- * @method ProductCategoryQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
- * @method ProductCategoryQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation
- *
* @method ProductCategoryQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
* @method ProductCategoryQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
* @method ProductCategoryQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
*
+ * @method ProductCategoryQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
+ * @method ProductCategoryQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
+ * @method ProductCategoryQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation
+ *
* @method ProductCategory findOne(PropelPDO $con = null) Return the first ProductCategory matching the query
* @method ProductCategory findOneOrCreate(PropelPDO $con = null) Return the first ProductCategory matching the query, or a new ProductCategory object populated from the query conditions when no match is found
*
@@ -61,7 +61,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ProductCategory', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ProductCategory', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -250,6 +250,8 @@ abstract class BaseProductCategoryQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProduct()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -277,6 +279,8 @@ abstract class BaseProductCategoryQuery extends ModelCriteria
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
*
*
+ * @see filterByCategory()
+ *
* @param mixed $categoryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -294,84 +298,10 @@ abstract class BaseProductCategoryQuery extends ModelCriteria
return $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId, $comparison);
}
- /**
- * Filter the query by a related Category object
- *
- * @param Category|PropelObjectCollection $category the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ProductCategoryQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByCategory($category, $comparison = null)
- {
- if ($category instanceof Category) {
- return $this
- ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->getId(), $comparison);
- } elseif ($category instanceof PropelObjectCollection) {
- return $this
- ->useCategoryQuery()
- ->filterByPrimaryKeys($category->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Category relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return ProductCategoryQuery The current query, for fluid interface
- */
- public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Category');
-
- // 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, 'Category');
- }
-
- return $this;
- }
-
- /**
- * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query
- */
- public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinCategory($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
- }
-
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product the related object 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 ProductCategoryQuery The current query, for fluid interface
@@ -383,10 +313,12 @@ abstract class BaseProductCategoryQuery extends ModelCriteria
return $this
->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
}
@@ -442,6 +374,82 @@ abstract class BaseProductCategoryQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
}
+ /**
+ * Filter the query by a related Category object
+ *
+ * @param Category|PropelObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductCategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof Category) {
+ return $this
+ ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ProductCategoryQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // 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, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseProductDesc.php b/core/lib/Thelia/Model/om/BaseProductDesc.php
index c2a0a91e6..220311ec5 100644
--- a/core/lib/Thelia/Model/om/BaseProductDesc.php
+++ b/core/lib/Thelia/Model/om/BaseProductDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Product;
use Thelia\Model\ProductDesc;
@@ -104,9 +102,9 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
protected $updatet_at;
/**
- * @var Product one-to-one related Product object
+ * @var Product
*/
- protected $singleProduct;
+ protected $aProduct;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -122,12 +120,6 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -283,6 +275,10 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = ProductDescPeer::PRODUCT_ID;
}
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
return $this;
} // setProductId()
@@ -508,6 +504,9 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
} // ensureConsistency
/**
@@ -547,8 +546,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleProduct = null;
-
+ $this->aProduct = null;
} // if (deep)
}
@@ -662,6 +660,18 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -673,21 +683,6 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -873,17 +868,23 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if (!$this->aProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
+ }
+ }
+
+
if (($retval = ProductDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -986,8 +987,8 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
$keys[8] => $this->getUpdatetAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1182,11 +1183,6 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1237,55 +1233,57 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Product object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Product
- * @throws PropelException
- */
- public function getProduct(PropelPDO $con = null)
- {
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleProduct;
- }
-
- /**
- * Sets a single Product object as related to this object by a one-to-one relationship.
- *
- * @param Product $v Product
+ * @param Product $v
* @return ProductDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setProduct(Product $v = null)
{
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getProductDesc() === null) {
- $v->setProductDesc($this);
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
}
+ $this->aProduct = $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 ($v !== null) {
+ $v->addProductDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Product object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
+ * @throws PropelException
+ */
+ public function getProduct(PropelPDO $con = null)
+ {
+ 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->aProduct->addProductDescs($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1320,15 +1318,9 @@ abstract class BaseProductDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
+ $this->aProduct = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseProductDescPeer.php b/core/lib/Thelia/Model/om/BaseProductDescPeer.php
index 70cf9defa..dfa73efe9 100644
--- a/core/lib/Thelia/Model/om/BaseProductDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseProductDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseProductDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'product_desc';
@@ -403,9 +403,6 @@ abstract class BaseProductDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
}
/**
@@ -502,6 +499,244 @@ abstract class BaseProductDescPeer
return array($obj, $col);
}
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ProductDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductDescPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ProductDesc 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
+ * @return array Array of ProductDesc objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME);
+ }
+
+ ProductDescPeer::addSelectColumns($criteria);
+ $startcol = ProductDescPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ProductDescPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ProductDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ProductDesc) to $obj2 (Product)
+ $obj2->addProductDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ProductDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductDescPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ProductDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ProductDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME);
+ }
+
+ ProductDescPeer::addSelectColumns($criteria);
+ $startcol2 = ProductDescPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ProductDescPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ProductDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ProductDesc) to the collection in $obj2 (Product)
+ $obj2->addProductDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -635,7 +870,6 @@ abstract class BaseProductDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ProductDescPeer::doOnDeleteCascade(new Criteria(ProductDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ProductDescPeer::TABLE_NAME, $con, ProductDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -669,14 +903,24 @@ abstract class BaseProductDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ProductDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ProductDesc) { // it's a model object
+ // invalidate the cache for this single object
+ ProductDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ProductDescPeer::DATABASE_NAME);
$criteria->add(ProductDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ProductDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -689,23 +933,6 @@ abstract class BaseProductDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ProductDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ProductDescPeer::clearInstancePool();
- } elseif ($values instanceof ProductDesc) { // it's a model object
- ProductDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ProductDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ProductDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -717,39 +944,6 @@ abstract class BaseProductDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ProductDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ProductDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseProductDescQuery.php b/core/lib/Thelia/Model/om/BaseProductDescQuery.php
index c31e2a2f3..bd0ecad55 100644
--- a/core/lib/Thelia/Model/om/BaseProductDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseProductDescQuery.php
@@ -84,7 +84,7 @@ abstract class BaseProductDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ProductDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ProductDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -287,6 +287,8 @@ abstract class BaseProductDescQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProduct()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -538,7 +540,7 @@ abstract class BaseProductDescQuery extends ModelCriteria
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product the related object 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 ProductDescQuery The current query, for fluid interface
@@ -550,10 +552,12 @@ abstract class BaseProductDescQuery extends ModelCriteria
return $this
->addUsingAlias(ProductDescPeer::PRODUCT_ID, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ProductDescPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseProductPeer.php b/core/lib/Thelia/Model/om/BaseProductPeer.php
index 049902aaa..52b5aaaf3 100644
--- a/core/lib/Thelia/Model/om/BaseProductPeer.php
+++ b/core/lib/Thelia/Model/om/BaseProductPeer.php
@@ -34,7 +34,7 @@ abstract class BaseProductPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'product';
@@ -437,9 +437,36 @@ abstract class BaseProductPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in TaxRulePeer instance pool,
+ // Invalidate objects in AccessoryPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- TaxRulePeer::clearInstancePool();
+ 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,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ RewritingPeer::clearInstancePool();
+ // Invalidate objects in StockPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ StockPeer::clearInstancePool();
}
/**
@@ -538,7 +565,7 @@ abstract class BaseProductPeer
/**
- * Returns the number of rows matching criteria, joining the related Accessory table
+ * Returns the number of rows matching criteria, joining the related TaxRule table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -546,7 +573,7 @@ abstract class BaseProductPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinAccessory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinTaxRule(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;
@@ -573,7 +600,7 @@ abstract class BaseProductPeer
$con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
+ $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -589,466 +616,7 @@ abstract class BaseProductPeer
/**
- * Returns the number of rows matching criteria, joining the related Accessory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAccessory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentAssoc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinContentAssoc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Document table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinDocument(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureProd table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinFeatureProd(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Image table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinImage(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ProductCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinProductCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ProductDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinProductDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Rewriting table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinRewriting(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Stock table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinStock(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their Accessory objects.
+ * Selects a collection of Product objects pre-filled with their TaxRule objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -1056,7 +624,7 @@ abstract class BaseProductPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -1067,9 +635,9 @@ abstract class BaseProductPeer
ProductPeer::addSelectColumns($criteria);
$startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- AccessoryPeer::addSelectColumns($criteria);
+ TaxRulePeer::addSelectColumns($criteria);
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
+ $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -1089,633 +657,20 @@ abstract class BaseProductPeer
ProductPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
+ $obj2 = TaxRulePeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = AccessoryPeer::getOMClass();
+ $cls = TaxRulePeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
+ TaxRulePeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (Product) to $obj2 (Accessory)
- // one to one relationship
- $obj1->setAccessory($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their Accessory objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- AccessoryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (Accessory)
- // one to one relationship
- $obj1->setAccessory($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their ContentAssoc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinContentAssoc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- ContentAssocPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (ContentAssoc)
- // one to one relationship
- $obj1->setContentAssoc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their Document objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- DocumentPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = DocumentPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- DocumentPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (Document)
- // one to one relationship
- $obj1->setDocument($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their FeatureProd objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinFeatureProd(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- FeatureProdPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = FeatureProdPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- FeatureProdPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (FeatureProd)
- // one to one relationship
- $obj1->setFeatureProd($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their Image objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- ImagePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ImagePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ImagePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (Image)
- // one to one relationship
- $obj1->setImage($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their ProductCategory objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinProductCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- ProductCategoryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ProductCategoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ProductCategoryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (ProductCategory)
- // one to one relationship
- $obj1->setProductCategory($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their ProductDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinProductDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- ProductDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ProductDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ProductDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (ProductDesc)
- // one to one relationship
- $obj1->setProductDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their Rewriting objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinRewriting(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- RewritingPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = RewritingPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- RewritingPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (Rewriting)
- // one to one relationship
- $obj1->setRewriting($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with their Stock objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinStock(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
- StockPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = StockPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = StockPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- StockPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Product) to $obj2 (Stock)
- // one to one relationship
- $obj1->setStock($obj2);
+ // Add the $obj1 (Product) to $obj2 (TaxRule)
+ $obj2->addProduct($obj1);
} // if joined row was not null
@@ -1763,25 +718,7 @@ abstract class BaseProductPeer
$con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
+ $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -1817,55 +754,10 @@ abstract class BaseProductPeer
ProductPeer::addSelectColumns($criteria);
$startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
+ TaxRulePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + TaxRulePeer::NUM_HYDRATE_COLUMNS;
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol12 = $startcol11 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
+ $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -1884,3464 +776,24 @@ abstract class BaseProductPeer
ProductPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined Accessory rows
+ // Add objects for joined TaxRule rows
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
+ $obj2 = TaxRulePeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = AccessoryPeer::getOMClass();
+ $cls = TaxRulePeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
+ TaxRulePeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
+ // Add the $obj1 (Product) to the collection in $obj2 (TaxRule)
+ $obj2->addProduct($obj1);
} // if joined row not null
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
- } // if joined row not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
- } // if joined row not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if obj5 loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
- } // if joined row not null
-
- // Add objects for joined FeatureProd rows
-
- $key6 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureProdPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureProdPeer::addInstanceToPool($obj6, $key6);
- } // if obj6 loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (FeatureProd)
- $obj1->setFeatureProd($obj6);
- } // if joined row not null
-
- // Add objects for joined Image rows
-
- $key7 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ImagePeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ImagePeer::addInstanceToPool($obj7, $key7);
- } // if obj7 loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (Image)
- $obj1->setImage($obj7);
- } // if joined row not null
-
- // Add objects for joined ProductCategory rows
-
- $key8 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductCategoryPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductCategoryPeer::addInstanceToPool($obj8, $key8);
- } // if obj8 loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductCategory)
- $obj1->setProductCategory($obj8);
- } // if joined row not null
-
- // Add objects for joined ProductDesc rows
-
- $key9 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = ProductDescPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- ProductDescPeer::addInstanceToPool($obj9, $key9);
- } // if obj9 loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (ProductDesc)
- $obj1->setProductDesc($obj9);
- } // if joined row not null
-
- // Add objects for joined Rewriting rows
-
- $key10 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = RewritingPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- RewritingPeer::addInstanceToPool($obj10, $key10);
- } // if obj10 loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Rewriting)
- $obj1->setRewriting($obj10);
- } // if joined row not null
-
- // Add objects for joined Stock rows
-
- $key11 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol11);
- if ($key11 !== null) {
- $obj11 = StockPeer::getInstanceFromPool($key11);
- if (!$obj11) {
-
- $cls = StockPeer::getOMClass();
-
- $obj11 = new $cls();
- $obj11->hydrate($row, $startcol11);
- StockPeer::addInstanceToPool($obj11, $key11);
- } // if obj11 loaded
-
- // Add the $obj1 (Product) to the collection in $obj11 (Stock)
- $obj1->setStock($obj11);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Accessory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAccessory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Accessory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptAccessory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ContentAssoc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptContentAssoc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Document table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptDocument(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related FeatureProd table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptFeatureProd(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Image table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptImage(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ProductCategory table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptProductCategory(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ProductDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptProductDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Rewriting table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptRewriting(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related Stock table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptStock(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ProductPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except Accessory.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentAssoc rows
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (ContentAssoc)
- $obj1->setContentAssoc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key3 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = DocumentPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- DocumentPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Document)
- $obj1->setDocument($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key4 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FeatureProdPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FeatureProdPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (FeatureProd)
- $obj1->setFeatureProd($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key5 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = ImagePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- ImagePeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Image)
- $obj1->setImage($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key6 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ProductCategoryPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ProductCategoryPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (ProductCategory)
- $obj1->setProductCategory($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key7 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductDescPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductDescPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (ProductDesc)
- $obj1->setProductDesc($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key9 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = StockPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = StockPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- StockPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (Stock)
- $obj1->setStock($obj9);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except Accessory.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ContentAssoc rows
-
- $key2 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ContentAssocPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ContentAssocPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (ContentAssoc)
- $obj1->setContentAssoc($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key3 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = DocumentPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- DocumentPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Document)
- $obj1->setDocument($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key4 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = FeatureProdPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- FeatureProdPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (FeatureProd)
- $obj1->setFeatureProd($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key5 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = ImagePeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- ImagePeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Image)
- $obj1->setImage($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key6 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ProductCategoryPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ProductCategoryPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (ProductCategory)
- $obj1->setProductCategory($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key7 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductDescPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductDescPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (ProductDesc)
- $obj1->setProductDesc($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key8 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = RewritingPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- RewritingPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (Rewriting)
- $obj1->setRewriting($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key9 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = StockPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = StockPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- StockPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (Stock)
- $obj1->setStock($obj9);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except ContentAssoc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptContentAssoc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Accessory rows
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key4 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = DocumentPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- DocumentPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (Document)
- $obj1->setDocument($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key5 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = FeatureProdPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- FeatureProdPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (FeatureProd)
- $obj1->setFeatureProd($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key8 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductDescPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductDescPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductDesc)
- $obj1->setProductDesc($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key9 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = RewritingPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- RewritingPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (Rewriting)
- $obj1->setRewriting($obj9);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key10 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = StockPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = StockPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- StockPeer::addInstanceToPool($obj10, $key10);
- } // if $obj10 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Stock)
- $obj1->setStock($obj10);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except Document.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Accessory rows
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key5 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = FeatureProdPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- FeatureProdPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (FeatureProd)
- $obj1->setFeatureProd($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key8 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductDescPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductDescPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductDesc)
- $obj1->setProductDesc($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key9 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = RewritingPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- RewritingPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (Rewriting)
- $obj1->setRewriting($obj9);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key10 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = StockPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = StockPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- StockPeer::addInstanceToPool($obj10, $key10);
- } // if $obj10 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Stock)
- $obj1->setStock($obj10);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except FeatureProd.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptFeatureProd(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Accessory rows
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key6 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = ImagePeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- ImagePeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (Image)
- $obj1->setImage($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key8 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductDescPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductDescPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductDesc)
- $obj1->setProductDesc($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key9 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = RewritingPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- RewritingPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (Rewriting)
- $obj1->setRewriting($obj9);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key10 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = StockPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = StockPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- StockPeer::addInstanceToPool($obj10, $key10);
- } // if $obj10 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Stock)
- $obj1->setStock($obj10);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except Image.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Accessory rows
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key6 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureProdPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureProdPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (FeatureProd)
- $obj1->setFeatureProd($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key7 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ProductCategoryPeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ProductCategoryPeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (ProductCategory)
- $obj1->setProductCategory($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key8 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductDescPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductDescPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductDesc)
- $obj1->setProductDesc($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key9 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = RewritingPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- RewritingPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (Rewriting)
- $obj1->setRewriting($obj9);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key10 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = StockPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = StockPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- StockPeer::addInstanceToPool($obj10, $key10);
- } // if $obj10 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Stock)
- $obj1->setStock($obj10);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except ProductCategory.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptProductCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Accessory rows
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key6 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureProdPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureProdPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (FeatureProd)
- $obj1->setFeatureProd($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key7 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ImagePeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ImagePeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (Image)
- $obj1->setImage($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key8 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductDescPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductDescPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductDesc)
- $obj1->setProductDesc($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key9 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = RewritingPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- RewritingPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (Rewriting)
- $obj1->setRewriting($obj9);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key10 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = StockPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = StockPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- StockPeer::addInstanceToPool($obj10, $key10);
- } // if $obj10 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Stock)
- $obj1->setStock($obj10);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except ProductDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptProductDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Accessory rows
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key6 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureProdPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureProdPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (FeatureProd)
- $obj1->setFeatureProd($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key7 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ImagePeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ImagePeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (Image)
- $obj1->setImage($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key8 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductCategoryPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductCategoryPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductCategory)
- $obj1->setProductCategory($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key9 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = RewritingPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- RewritingPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (Rewriting)
- $obj1->setRewriting($obj9);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key10 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = StockPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = StockPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- StockPeer::addInstanceToPool($obj10, $key10);
- } // if $obj10 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Stock)
- $obj1->setStock($obj10);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except Rewriting.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptRewriting(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- StockPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + StockPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, StockPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Accessory rows
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key6 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureProdPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureProdPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (FeatureProd)
- $obj1->setFeatureProd($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key7 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ImagePeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ImagePeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (Image)
- $obj1->setImage($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key8 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductCategoryPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductCategoryPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductCategory)
- $obj1->setProductCategory($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key9 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = ProductDescPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- ProductDescPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (ProductDesc)
- $obj1->setProductDesc($obj9);
-
- } // if joined row is not null
-
- // Add objects for joined Stock rows
-
- $key10 = StockPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = StockPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = StockPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- StockPeer::addInstanceToPool($obj10, $key10);
- } // if $obj10 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Stock)
- $obj1->setStock($obj10);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Product objects pre-filled with all related objects except Stock.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Product objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptStock(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ProductPeer::DATABASE_NAME);
- }
-
- ProductPeer::addSelectColumns($criteria);
- $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- AccessoryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + AccessoryPeer::NUM_HYDRATE_COLUMNS;
-
- ContentAssocPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
-
- DocumentPeer::addSelectColumns($criteria);
- $startcol6 = $startcol5 + DocumentPeer::NUM_HYDRATE_COLUMNS;
-
- FeatureProdPeer::addSelectColumns($criteria);
- $startcol7 = $startcol6 + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
-
- ImagePeer::addSelectColumns($criteria);
- $startcol8 = $startcol7 + ImagePeer::NUM_HYDRATE_COLUMNS;
-
- ProductCategoryPeer::addSelectColumns($criteria);
- $startcol9 = $startcol8 + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
-
- ProductDescPeer::addSelectColumns($criteria);
- $startcol10 = $startcol9 + ProductDescPeer::NUM_HYDRATE_COLUMNS;
-
- RewritingPeer::addSelectColumns($criteria);
- $startcol11 = $startcol10 + RewritingPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, AccessoryPeer::ACCESSORY, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ContentAssocPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, DocumentPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, FeatureProdPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ImagePeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductCategoryPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, ProductDescPeer::PRODUCT_ID, $join_behavior);
-
- $criteria->addJoin(ProductPeer::ID, RewritingPeer::PRODUCT_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ProductPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ProductPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Accessory rows
-
- $key2 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = AccessoryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- AccessoryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj2 (Accessory)
- $obj1->setAccessory($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined Accessory rows
-
- $key3 = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = AccessoryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = AccessoryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- AccessoryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj3 (Accessory)
- $obj1->setAccessory($obj3);
-
- } // if joined row is not null
-
- // Add objects for joined ContentAssoc rows
-
- $key4 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = ContentAssocPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = ContentAssocPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- ContentAssocPeer::addInstanceToPool($obj4, $key4);
- } // if $obj4 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj4 (ContentAssoc)
- $obj1->setContentAssoc($obj4);
-
- } // if joined row is not null
-
- // Add objects for joined Document rows
-
- $key5 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
- if ($key5 !== null) {
- $obj5 = DocumentPeer::getInstanceFromPool($key5);
- if (!$obj5) {
-
- $cls = DocumentPeer::getOMClass();
-
- $obj5 = new $cls();
- $obj5->hydrate($row, $startcol5);
- DocumentPeer::addInstanceToPool($obj5, $key5);
- } // if $obj5 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj5 (Document)
- $obj1->setDocument($obj5);
-
- } // if joined row is not null
-
- // Add objects for joined FeatureProd rows
-
- $key6 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol6);
- if ($key6 !== null) {
- $obj6 = FeatureProdPeer::getInstanceFromPool($key6);
- if (!$obj6) {
-
- $cls = FeatureProdPeer::getOMClass();
-
- $obj6 = new $cls();
- $obj6->hydrate($row, $startcol6);
- FeatureProdPeer::addInstanceToPool($obj6, $key6);
- } // if $obj6 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj6 (FeatureProd)
- $obj1->setFeatureProd($obj6);
-
- } // if joined row is not null
-
- // Add objects for joined Image rows
-
- $key7 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol7);
- if ($key7 !== null) {
- $obj7 = ImagePeer::getInstanceFromPool($key7);
- if (!$obj7) {
-
- $cls = ImagePeer::getOMClass();
-
- $obj7 = new $cls();
- $obj7->hydrate($row, $startcol7);
- ImagePeer::addInstanceToPool($obj7, $key7);
- } // if $obj7 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj7 (Image)
- $obj1->setImage($obj7);
-
- } // if joined row is not null
-
- // Add objects for joined ProductCategory rows
-
- $key8 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol8);
- if ($key8 !== null) {
- $obj8 = ProductCategoryPeer::getInstanceFromPool($key8);
- if (!$obj8) {
-
- $cls = ProductCategoryPeer::getOMClass();
-
- $obj8 = new $cls();
- $obj8->hydrate($row, $startcol8);
- ProductCategoryPeer::addInstanceToPool($obj8, $key8);
- } // if $obj8 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj8 (ProductCategory)
- $obj1->setProductCategory($obj8);
-
- } // if joined row is not null
-
- // Add objects for joined ProductDesc rows
-
- $key9 = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol9);
- if ($key9 !== null) {
- $obj9 = ProductDescPeer::getInstanceFromPool($key9);
- if (!$obj9) {
-
- $cls = ProductDescPeer::getOMClass();
-
- $obj9 = new $cls();
- $obj9->hydrate($row, $startcol9);
- ProductDescPeer::addInstanceToPool($obj9, $key9);
- } // if $obj9 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj9 (ProductDesc)
- $obj1->setProductDesc($obj9);
-
- } // if joined row is not null
-
- // Add objects for joined Rewriting rows
-
- $key10 = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol10);
- if ($key10 !== null) {
- $obj10 = RewritingPeer::getInstanceFromPool($key10);
- if (!$obj10) {
-
- $cls = RewritingPeer::getOMClass();
-
- $obj10 = new $cls();
- $obj10->hydrate($row, $startcol10);
- RewritingPeer::addInstanceToPool($obj10, $key10);
- } // if $obj10 already loaded
-
- // Add the $obj1 (Product) to the collection in $obj10 (Rewriting)
- $obj1->setRewriting($obj10);
-
- } // if joined row is not null
-
$results[] = $obj1;
}
$stmt->closeCursor();
@@ -5482,7 +934,6 @@ abstract class BaseProductPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- ProductPeer::doOnDeleteSetNull(new Criteria(ProductPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ProductPeer::TABLE_NAME, $con, ProductPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -5516,14 +967,24 @@ abstract class BaseProductPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ProductPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Product) { // it's a model object
+ // invalidate the cache for this single object
+ ProductPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ProductPeer::DATABASE_NAME);
$criteria->add(ProductPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ProductPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -5536,23 +997,6 @@ abstract class BaseProductPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- ProductPeer::doOnDeleteSetNull($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ProductPeer::clearInstancePool();
- } elseif ($values instanceof Product) { // it's a model object
- ProductPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ProductPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ProductPeer::clearRelatedInstancePool();
$con->commit();
@@ -5564,37 +1008,6 @@ abstract class BaseProductPeer
}
}
- /**
- * This is a method for emulating ON DELETE SET NULL DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return void
- */
- protected static function doOnDeleteSetNull(Criteria $criteria, PropelPDO $con)
- {
-
- // first find the objects that are implicated by the $criteria
- $objects = ProductPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
- // set fkey col in related TaxRule rows to null
- $selectCriteria = new Criteria(ProductPeer::DATABASE_NAME);
- $updateValues = new Criteria(ProductPeer::DATABASE_NAME);
- $selectCriteria->add(TaxRulePeer::ID, $obj->getTaxRuleId());
- $updateValues->add(TaxRulePeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- }
- }
-
/**
* Validates all modified columns of given Product object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseProductQuery.php b/core/lib/Thelia/Model/om/BaseProductQuery.php
index 8066c0c75..0bd645f34 100644
--- a/core/lib/Thelia/Model/om/BaseProductQuery.php
+++ b/core/lib/Thelia/Model/om/BaseProductQuery.php
@@ -65,13 +65,17 @@ use Thelia\Model\TaxRule;
* @method ProductQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ProductQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method ProductQuery leftJoinAccessory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Accessory relation
- * @method ProductQuery rightJoinAccessory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Accessory relation
- * @method ProductQuery innerJoinAccessory($relationAlias = null) Adds a INNER JOIN clause to the query using the Accessory relation
+ * @method ProductQuery leftJoinTaxRule($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaxRule relation
+ * @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 leftJoinAccessory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Accessory relation
- * @method ProductQuery rightJoinAccessory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Accessory relation
- * @method ProductQuery innerJoinAccessory($relationAlias = null) Adds a INNER JOIN clause to the query using the Accessory 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
+ *
+ * @method ProductQuery leftJoinAccessoryRelatedByAccessory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AccessoryRelatedByAccessory relation
+ * @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
@@ -105,10 +109,6 @@ use Thelia\Model\TaxRule;
* @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 leftJoinTaxRule($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaxRule relation
- * @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 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
*
@@ -153,7 +153,7 @@ abstract class BaseProductQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Product', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Product', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -329,26 +329,6 @@ abstract class BaseProductQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByAccessory()
- *
- * @see filterByAccessory()
- *
- * @see filterByContentAssoc()
- *
- * @see filterByDocument()
- *
- * @see filterByFeatureProd()
- *
- * @see filterByImage()
- *
- * @see filterByProductCategory()
- *
- * @see filterByProductDesc()
- *
- * @see filterByRewriting()
- *
- * @see filterByStock()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -376,6 +356,8 @@ abstract class BaseProductQuery extends ModelCriteria
* $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
*
*
+ * @see filterByTaxRule()
+ *
* @param mixed $taxRuleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -892,43 +874,117 @@ abstract class BaseProductQuery extends ModelCriteria
}
/**
- * Filter the query by a related Accessory object
+ * Filter the query by a related TaxRule object
*
- * @param Accessory|PropelObjectCollection $accessory The related object(s) to use as filter
+ * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ProductQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByAccessory($accessory, $comparison = null)
+ public function filterByTaxRule($taxRule, $comparison = null)
+ {
+ if ($taxRule instanceof TaxRule) {
+ return $this
+ ->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRule->getId(), $comparison);
+ } elseif ($taxRule instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRule 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 joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRule');
+
+ // 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, 'TaxRule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRule relation TaxRule 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\TaxRuleQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
+ }
+
+ /**
+ * Filter the query by a related Accessory object
+ *
+ * @param Accessory|PropelObjectCollection $accessory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAccessoryRelatedByProductId($accessory, $comparison = null)
{
if ($accessory instanceof Accessory) {
return $this
->addUsingAlias(ProductPeer::ID, $accessory->getProductId(), $comparison);
} elseif ($accessory instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $accessory->toKeyValue('PrimaryKey', 'ProductId'), $comparison);
+ ->useAccessoryRelatedByProductIdQuery()
+ ->filterByPrimaryKeys($accessory->getPrimaryKeys())
+ ->endUse();
} else {
- throw new PropelException('filterByAccessory() only accepts arguments of type Accessory or PropelCollection');
+ throw new PropelException('filterByAccessoryRelatedByProductId() only accepts arguments of type Accessory or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the Accessory relation
+ * Adds a JOIN clause to the query using the AccessoryRelatedByProductId 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 joinAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinAccessoryRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Accessory');
+ $relationMap = $tableMap->getRelation('AccessoryRelatedByProductId');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -943,14 +999,14 @@ abstract class BaseProductQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'Accessory');
+ $this->addJoinObject($join, 'AccessoryRelatedByProductId');
}
return $this;
}
/**
- * Use the Accessory relation Accessory object
+ * Use the AccessoryRelatedByProductId relation Accessory object
*
* @see useQuery()
*
@@ -960,51 +1016,49 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return \Thelia\Model\AccessoryQuery A secondary query class using the current class as primary query
*/
- public function useAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useAccessoryRelatedByProductIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
- ->joinAccessory($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Accessory', '\Thelia\Model\AccessoryQuery');
+ ->joinAccessoryRelatedByProductId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AccessoryRelatedByProductId', '\Thelia\Model\AccessoryQuery');
}
/**
* Filter the query by a related Accessory object
*
- * @param Accessory|PropelObjectCollection $accessory The related object(s) to use as filter
+ * @param Accessory|PropelObjectCollection $accessory the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ProductQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByAccessory($accessory, $comparison = null)
+ public function filterByAccessoryRelatedByAccessory($accessory, $comparison = null)
{
if ($accessory instanceof Accessory) {
return $this
->addUsingAlias(ProductPeer::ID, $accessory->getAccessory(), $comparison);
} elseif ($accessory instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $accessory->toKeyValue('PrimaryKey', 'Accessory'), $comparison);
+ ->useAccessoryRelatedByAccessoryQuery()
+ ->filterByPrimaryKeys($accessory->getPrimaryKeys())
+ ->endUse();
} else {
- throw new PropelException('filterByAccessory() only accepts arguments of type Accessory or PropelCollection');
+ throw new PropelException('filterByAccessoryRelatedByAccessory() only accepts arguments of type Accessory or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the Accessory relation
+ * Adds a JOIN clause to the query using the AccessoryRelatedByAccessory 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 joinAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinAccessoryRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Accessory');
+ $relationMap = $tableMap->getRelation('AccessoryRelatedByAccessory');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -1019,14 +1073,14 @@ abstract class BaseProductQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'Accessory');
+ $this->addJoinObject($join, 'AccessoryRelatedByAccessory');
}
return $this;
}
/**
- * Use the Accessory relation Accessory object
+ * Use the AccessoryRelatedByAccessory relation Accessory object
*
* @see useQuery()
*
@@ -1036,17 +1090,17 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return \Thelia\Model\AccessoryQuery A secondary query class using the current class as primary query
*/
- public function useAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useAccessoryRelatedByAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
- ->joinAccessory($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Accessory', '\Thelia\Model\AccessoryQuery');
+ ->joinAccessoryRelatedByAccessory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AccessoryRelatedByAccessory', '\Thelia\Model\AccessoryQuery');
}
/**
* Filter the query by a related ContentAssoc object
*
- * @param ContentAssoc|PropelObjectCollection $contentAssoc The related object(s) 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 ProductQuery The current query, for fluid interface
@@ -1058,12 +1112,10 @@ abstract class BaseProductQuery extends ModelCriteria
return $this
->addUsingAlias(ProductPeer::ID, $contentAssoc->getProductId(), $comparison);
} elseif ($contentAssoc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $contentAssoc->toKeyValue('PrimaryKey', 'ProductId'), $comparison);
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection');
}
@@ -1077,7 +1129,7 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return ProductQuery The current query, for fluid interface
*/
- public function joinContentAssoc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('ContentAssoc');
@@ -1112,7 +1164,7 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
*/
- public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinContentAssoc($relationAlias, $joinType)
@@ -1122,7 +1174,7 @@ abstract class BaseProductQuery extends ModelCriteria
/**
* Filter the query by a related Document object
*
- * @param Document|PropelObjectCollection $document The related object(s) 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 ProductQuery The current query, for fluid interface
@@ -1134,12 +1186,10 @@ abstract class BaseProductQuery extends ModelCriteria
return $this
->addUsingAlias(ProductPeer::ID, $document->getProductId(), $comparison);
} elseif ($document instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $document->toKeyValue('PrimaryKey', 'ProductId'), $comparison);
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
}
@@ -1153,7 +1203,7 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return ProductQuery The current query, for fluid interface
*/
- public function joinDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Document');
@@ -1188,7 +1238,7 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
*/
- public function useDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinDocument($relationAlias, $joinType)
@@ -1198,7 +1248,7 @@ abstract class BaseProductQuery extends ModelCriteria
/**
* Filter the query by a related FeatureProd object
*
- * @param FeatureProd|PropelObjectCollection $featureProd The related object(s) to use as filter
+ * @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
@@ -1210,12 +1260,10 @@ abstract class BaseProductQuery extends ModelCriteria
return $this
->addUsingAlias(ProductPeer::ID, $featureProd->getProductId(), $comparison);
} elseif ($featureProd instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $featureProd->toKeyValue('PrimaryKey', 'ProductId'), $comparison);
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection');
}
@@ -1274,7 +1322,7 @@ abstract class BaseProductQuery extends ModelCriteria
/**
* Filter the query by a related Image object
*
- * @param Image|PropelObjectCollection $image The related object(s) to use as filter
+ * @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
@@ -1286,12 +1334,10 @@ abstract class BaseProductQuery extends ModelCriteria
return $this
->addUsingAlias(ProductPeer::ID, $image->getProductId(), $comparison);
} elseif ($image instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $image->toKeyValue('PrimaryKey', 'ProductId'), $comparison);
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
}
@@ -1305,7 +1351,7 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return ProductQuery The current query, for fluid interface
*/
- public function joinImage($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Image');
@@ -1340,7 +1386,7 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
*/
- public function useImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinImage($relationAlias, $joinType)
@@ -1350,7 +1396,7 @@ abstract class BaseProductQuery extends ModelCriteria
/**
* Filter the query by a related ProductCategory object
*
- * @param ProductCategory|PropelObjectCollection $productCategory The related object(s) 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 ProductQuery The current query, for fluid interface
@@ -1362,12 +1408,10 @@ abstract class BaseProductQuery extends ModelCriteria
return $this
->addUsingAlias(ProductPeer::ID, $productCategory->getProductId(), $comparison);
} elseif ($productCategory instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $productCategory->toKeyValue('ProductId', 'ProductId'), $comparison);
+ ->useProductCategoryQuery()
+ ->filterByPrimaryKeys($productCategory->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection');
}
@@ -1426,7 +1470,7 @@ abstract class BaseProductQuery extends ModelCriteria
/**
* Filter the query by a related ProductDesc object
*
- * @param ProductDesc|PropelObjectCollection $productDesc The related object(s) to use as filter
+ * @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
@@ -1438,12 +1482,10 @@ abstract class BaseProductQuery extends ModelCriteria
return $this
->addUsingAlias(ProductPeer::ID, $productDesc->getProductId(), $comparison);
} elseif ($productDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $productDesc->toKeyValue('PrimaryKey', 'ProductId'), $comparison);
+ ->useProductDescQuery()
+ ->filterByPrimaryKeys($productDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByProductDesc() only accepts arguments of type ProductDesc or PropelCollection');
}
@@ -1502,7 +1544,7 @@ abstract class BaseProductQuery extends ModelCriteria
/**
* Filter the query by a related Rewriting object
*
- * @param Rewriting|PropelObjectCollection $rewriting The related object(s) to use as filter
+ * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ProductQuery The current query, for fluid interface
@@ -1514,12 +1556,10 @@ abstract class BaseProductQuery extends ModelCriteria
return $this
->addUsingAlias(ProductPeer::ID, $rewriting->getProductId(), $comparison);
} elseif ($rewriting instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $rewriting->toKeyValue('PrimaryKey', 'ProductId'), $comparison);
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection');
}
@@ -1533,7 +1573,7 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return ProductQuery The current query, for fluid interface
*/
- public function joinRewriting($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Rewriting');
@@ -1568,7 +1608,7 @@ abstract class BaseProductQuery extends ModelCriteria
*
* @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query
*/
- public function useRewritingQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinRewriting($relationAlias, $joinType)
@@ -1578,7 +1618,7 @@ abstract class BaseProductQuery extends ModelCriteria
/**
* Filter the query by a related Stock object
*
- * @param Stock|PropelObjectCollection $stock The related object(s) to use as filter
+ * @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
@@ -1590,12 +1630,10 @@ abstract class BaseProductQuery extends ModelCriteria
return $this
->addUsingAlias(ProductPeer::ID, $stock->getProductId(), $comparison);
} elseif ($stock instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ProductPeer::ID, $stock->toKeyValue('PrimaryKey', 'ProductId'), $comparison);
+ ->useStockQuery()
+ ->filterByPrimaryKeys($stock->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection');
}
@@ -1651,80 +1689,6 @@ abstract class BaseProductQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery');
}
- /**
- * Filter the query by a related TaxRule object
- *
- * @param TaxRule|PropelObjectCollection $taxRule 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 filterByTaxRule($taxRule, $comparison = null)
- {
- if ($taxRule instanceof TaxRule) {
- return $this
- ->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRule->getId(), $comparison);
- } elseif ($taxRule instanceof PropelObjectCollection) {
- return $this
- ->useTaxRuleQuery()
- ->filterByPrimaryKeys($taxRule->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the TaxRule 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 joinTaxRule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('TaxRule');
-
- // 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, 'TaxRule');
- }
-
- return $this;
- }
-
- /**
- * Use the TaxRule relation TaxRule 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\TaxRuleQuery A secondary query class using the current class as primary query
- */
- public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinTaxRule($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
- }
-
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseResource.php b/core/lib/Thelia/Model/om/BaseResource.php
index ac134afc2..f6c844fb8 100644
--- a/core/lib/Thelia/Model/om/BaseResource.php
+++ b/core/lib/Thelia/Model/om/BaseResource.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\GroupResource;
use Thelia\Model\GroupResourceQuery;
@@ -74,14 +76,16 @@ abstract class BaseResource extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var GroupResource
+ * @var PropelObjectCollection|GroupResource[] Collection to store aggregation of GroupResource objects.
*/
- protected $aGroupResource;
+ protected $collGroupResources;
+ protected $collGroupResourcesPartial;
/**
- * @var ResourceDesc
+ * @var PropelObjectCollection|ResourceDesc[] Collection to store aggregation of ResourceDesc objects.
*/
- protected $aResourceDesc;
+ protected $collResourceDescs;
+ protected $collResourceDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -97,6 +101,18 @@ abstract class BaseResource extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $groupResourcesScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $resourceDescsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -208,14 +224,6 @@ abstract class BaseResource extends BaseObject implements Persistent
$this->modifiedColumns[] = ResourcePeer::ID;
}
- if ($this->aGroupResource !== null && $this->aGroupResource->getResourceId() !== $v) {
- $this->aGroupResource = null;
- }
-
- if ($this->aResourceDesc !== null && $this->aResourceDesc->getResourceId() !== $v) {
- $this->aResourceDesc = null;
- }
-
return $this;
} // setId()
@@ -354,12 +362,6 @@ abstract class BaseResource extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aGroupResource !== null && $this->id !== $this->aGroupResource->getResourceId()) {
- $this->aGroupResource = null;
- }
- if ($this->aResourceDesc !== null && $this->id !== $this->aResourceDesc->getResourceId()) {
- $this->aResourceDesc = null;
- }
} // ensureConsistency
/**
@@ -399,8 +401,10 @@ abstract class BaseResource extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aGroupResource = null;
- $this->aResourceDesc = null;
+ $this->collGroupResources = null;
+
+ $this->collResourceDescs = null;
+
} // if (deep)
}
@@ -514,25 +518,6 @@ abstract class BaseResource extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aGroupResource !== null) {
- if ($this->aGroupResource->isModified() || $this->aGroupResource->isNew()) {
- $affectedRows += $this->aGroupResource->save($con);
- }
- $this->setGroupResource($this->aGroupResource);
- }
-
- if ($this->aResourceDesc !== null) {
- if ($this->aResourceDesc->isModified() || $this->aResourceDesc->isNew()) {
- $affectedRows += $this->aResourceDesc->save($con);
- }
- $this->setResourceDesc($this->aResourceDesc);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -544,6 +529,40 @@ 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()
+ ->filterByPrimaryKeys($this->resourceDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->resourceDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collResourceDescs !== null) {
+ foreach ($this->collResourceDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -699,29 +718,27 @@ abstract class BaseResource extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aGroupResource !== null) {
- if (!$this->aGroupResource->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aGroupResource->getValidationFailures());
- }
- }
-
- if ($this->aResourceDesc !== null) {
- if (!$this->aResourceDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aResourceDesc->getValidationFailures());
- }
- }
-
-
if (($retval = ResourcePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collGroupResources !== null) {
+ foreach ($this->collGroupResources as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collResourceDescs !== null) {
+ foreach ($this->collResourceDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -804,11 +821,11 @@ abstract class BaseResource extends BaseObject implements Persistent
$keys[3] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aGroupResource) {
- $result['GroupResource'] = $this->aGroupResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collGroupResources) {
+ $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aResourceDesc) {
- $result['ResourceDesc'] = $this->aResourceDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collResourceDescs) {
+ $result['ResourceDescs'] = $this->collResourceDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -973,14 +990,16 @@ abstract class BaseResource extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getGroupResource();
- if ($relObj) {
- $copyObj->setGroupResource($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));
+ }
}
- $relObj = $this->getResourceDesc();
- if ($relObj) {
- $copyObj->setResourceDesc($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));
+ }
}
//unflag object copy
@@ -1033,98 +1052,462 @@ abstract class BaseResource extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a GroupResource object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param GroupResource $v
- * @return Resource The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('GroupResource' == $relationName) {
+ $this->initGroupResources();
+ }
+ if ('ResourceDesc' == $relationName) {
+ $this->initResourceDescs();
+ }
+ }
+
+ /**
+ * 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 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|GroupResource[] List of GroupResource objects
* @throws PropelException
*/
- public function setGroupResource(GroupResource $v = null)
+ public function getGroupResources($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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)
+ ->filterByResource($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->setResource(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
+ ->filterByResource($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getResourceId());
+ return count($this->collGroupResources);
}
+ }
- $this->aGroupResource = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setResource($this);
+ /**
+ * Method called to associate a GroupResource object to this object
+ * through the GroupResource foreign key attribute.
+ *
+ * @param GroupResource $l GroupResource
+ * @return Resource 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;
}
-
/**
- * Get the associated GroupResource object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return GroupResource The associated GroupResource object.
- * @throws PropelException
+ * @param GroupResource $groupResource The groupResource object to add.
*/
- public function getGroupResource(PropelPDO $con = null)
+ protected function doAddGroupResource($groupResource)
{
- if ($this->aGroupResource === null && ($this->id !== null)) {
- $this->aGroupResource = GroupResourceQuery::create()
- ->filterByResource($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aGroupResource->setResource($this);
- }
-
- return $this->aGroupResource;
+ $this->collGroupResources[]= $groupResource;
+ $groupResource->setResource($this);
}
/**
- * Declares an association between this object and a ResourceDesc object.
+ * @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->setResource(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Resource is new, it will return
+ * an empty collection; or if this Resource has previously
+ * been saved, it will retrieve related GroupResources from storage.
*
- * @param ResourceDesc $v
- * @return Resource The current object (for fluent API support)
+ * 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 Resource.
+ *
+ * @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 getGroupResourcesJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = GroupResourceQuery::create(null, $criteria);
+ $query->joinWith('Group', $join_behavior);
+
+ 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 setResourceDesc(ResourceDesc $v = null)
+ public function getResourceDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getResourceId());
+ return count($this->collResourceDescs);
}
+ }
- $this->aResourceDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setResource($this);
+ /**
+ * 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);
+ }
/**
- * Get the associated ResourceDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return ResourceDesc The associated ResourceDesc object.
- * @throws PropelException
+ * @param ResourceDesc $resourceDesc The resourceDesc object to remove.
*/
- public function getResourceDesc(PropelPDO $con = null)
+ public function removeResourceDesc($resourceDesc)
{
- if ($this->aResourceDesc === null && ($this->id !== null)) {
- $this->aResourceDesc = ResourceDescQuery::create()
- ->filterByResource($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aResourceDesc->setResource($this);
+ 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);
}
-
- return $this->aResourceDesc;
}
/**
@@ -1156,10 +1539,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 ($deep)
- $this->aGroupResource = null;
- $this->aResourceDesc = null;
+ if ($this->collGroupResources instanceof PropelCollection) {
+ $this->collGroupResources->clearIterator();
+ }
+ $this->collGroupResources = null;
+ if ($this->collResourceDescs instanceof PropelCollection) {
+ $this->collResourceDescs->clearIterator();
+ }
+ $this->collResourceDescs = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseResourceDesc.php b/core/lib/Thelia/Model/om/BaseResourceDesc.php
index 9e372251b..cb9f40450 100644
--- a/core/lib/Thelia/Model/om/BaseResourceDesc.php
+++ b/core/lib/Thelia/Model/om/BaseResourceDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Resource;
use Thelia\Model\ResourceDesc;
@@ -86,9 +84,9 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Resource one-to-one related Resource object
+ * @var Resource
*/
- protected $singleResource;
+ protected $aResource;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -104,12 +102,6 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $resourcesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -262,6 +254,10 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = ResourceDescPeer::RESOURCE_ID;
}
+ if ($this->aResource !== null && $this->aResource->getId() !== $v) {
+ $this->aResource = null;
+ }
+
return $this;
} // setResourceId()
@@ -423,6 +419,9 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aResource !== null && $this->resource_id !== $this->aResource->getId()) {
+ $this->aResource = null;
+ }
} // ensureConsistency
/**
@@ -462,8 +461,7 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleResource = null;
-
+ $this->aResource = null;
} // if (deep)
}
@@ -577,6 +575,18 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aResource !== null) {
+ if ($this->aResource->isModified() || $this->aResource->isNew()) {
+ $affectedRows += $this->aResource->save($con);
+ }
+ $this->setResource($this->aResource);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -588,21 +598,6 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->resourcesScheduledForDeletion !== null) {
- if (!$this->resourcesScheduledForDeletion->isEmpty()) {
- ResourceQuery::create()
- ->filterByPrimaryKeys($this->resourcesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->resourcesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleResource !== null) {
- if (!$this->singleResource->isDeleted()) {
- $affectedRows += $this->singleResource->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -770,17 +765,23 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aResource !== null) {
+ if (!$this->aResource->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aResource->getValidationFailures());
+ }
+ }
+
+
if (($retval = ResourceDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleResource !== null) {
- if (!$this->singleResource->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleResource->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -871,8 +872,8 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
$keys[5] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleResource) {
- $result['Resource'] = $this->singleResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aResource) {
+ $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1049,11 +1050,6 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getResource();
- if ($relObj) {
- $copyObj->setResource($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1104,55 +1100,57 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Resource object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Resource object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Resource
- * @throws PropelException
- */
- public function getResource(PropelPDO $con = null)
- {
-
- if ($this->singleResource === null && !$this->isNew()) {
- $this->singleResource = ResourceQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleResource;
- }
-
- /**
- * Sets a single Resource object as related to this object by a one-to-one relationship.
- *
- * @param Resource $v Resource
+ * @param Resource $v
* @return ResourceDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setResource(Resource $v = null)
{
- $this->singleResource = $v;
-
- // Make sure that that the passed-in Resource isn't already associated with this object
- if ($v !== null && $v->getResourceDesc() === null) {
- $v->setResourceDesc($this);
+ if ($v === null) {
+ $this->setResourceId(NULL);
+ } else {
+ $this->setResourceId($v->getId());
}
+ $this->aResource = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Resource object, it will not be re-added.
+ if ($v !== null) {
+ $v->addResourceDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Resource object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Resource The associated Resource object.
+ * @throws PropelException
+ */
+ public function getResource(PropelPDO $con = null)
+ {
+ if ($this->aResource === null && ($this->resource_id !== null)) {
+ $this->aResource = ResourceQuery::create()->findPk($this->resource_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->aResource->addResourceDescs($this);
+ */
+ }
+
+ return $this->aResource;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1184,15 +1182,9 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleResource) {
- $this->singleResource->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleResource instanceof PropelCollection) {
- $this->singleResource->clearIterator();
- }
- $this->singleResource = null;
+ $this->aResource = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseResourceDescPeer.php b/core/lib/Thelia/Model/om/BaseResourceDescPeer.php
index 31b658bc0..1c2095508 100644
--- a/core/lib/Thelia/Model/om/BaseResourceDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseResourceDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseResourceDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'resource_desc';
@@ -388,9 +388,6 @@ abstract class BaseResourceDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in ResourcePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ResourcePeer::clearInstancePool();
}
/**
@@ -487,6 +484,244 @@ abstract class BaseResourceDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Resource table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinResource(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ResourceDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ResourceDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ResourceDescPeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ResourceDesc objects pre-filled with their Resource objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ResourceDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME);
+ }
+
+ ResourceDescPeer::addSelectColumns($criteria);
+ $startcol = ResourceDescPeer::NUM_HYDRATE_COLUMNS;
+ ResourcePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ResourceDescPeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ResourceDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ResourceDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ResourceDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ResourceDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ResourcePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ResourcePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ResourcePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ResourceDesc) to $obj2 (Resource)
+ $obj2->addResourceDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ResourceDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ResourceDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ResourceDescPeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ResourceDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ResourceDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME);
+ }
+
+ ResourceDescPeer::addSelectColumns($criteria);
+ $startcol2 = ResourceDescPeer::NUM_HYDRATE_COLUMNS;
+
+ ResourcePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ResourcePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ResourceDescPeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ResourceDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ResourceDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ResourceDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ResourceDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Resource rows
+
+ $key2 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ResourcePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ResourcePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ResourcePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ResourceDesc) to the collection in $obj2 (Resource)
+ $obj2->addResourceDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -620,7 +855,6 @@ abstract class BaseResourceDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += ResourceDescPeer::doOnDeleteCascade(new Criteria(ResourceDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(ResourceDescPeer::TABLE_NAME, $con, ResourceDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -654,14 +888,24 @@ abstract class BaseResourceDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ResourceDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof ResourceDesc) { // it's a model object
+ // invalidate the cache for this single object
+ ResourceDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ResourceDescPeer::DATABASE_NAME);
$criteria->add(ResourceDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ResourceDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -674,23 +918,6 @@ abstract class BaseResourceDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += ResourceDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- ResourceDescPeer::clearInstancePool();
- } elseif ($values instanceof ResourceDesc) { // it's a model object
- ResourceDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- ResourceDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
ResourceDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -702,39 +929,6 @@ abstract class BaseResourceDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = ResourceDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Resource objects
- $criteria = new Criteria(ResourcePeer::DATABASE_NAME);
-
- $criteria->add(ResourcePeer::ID, $obj->getResourceId());
- $affectedRows += ResourcePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given ResourceDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseResourceDescQuery.php b/core/lib/Thelia/Model/om/BaseResourceDescQuery.php
index cfa7f808d..96116f0b5 100644
--- a/core/lib/Thelia/Model/om/BaseResourceDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseResourceDescQuery.php
@@ -72,7 +72,7 @@ abstract class BaseResourceDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\ResourceDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ResourceDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -275,6 +275,8 @@ abstract class BaseResourceDescQuery extends ModelCriteria
* $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12
*
*
+ * @see filterByResource()
+ *
* @param mixed $resourceId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -453,7 +455,7 @@ abstract class BaseResourceDescQuery extends ModelCriteria
/**
* Filter the query by a related Resource object
*
- * @param Resource|PropelObjectCollection $resource the related object to use as filter
+ * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ResourceDescQuery The current query, for fluid interface
@@ -465,10 +467,12 @@ abstract class BaseResourceDescQuery extends ModelCriteria
return $this
->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resource->getId(), $comparison);
} elseif ($resource instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useResourceQuery()
- ->filterByPrimaryKeys($resource->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseResourcePeer.php b/core/lib/Thelia/Model/om/BaseResourcePeer.php
index b83e40665..8e8b5754c 100644
--- a/core/lib/Thelia/Model/om/BaseResourcePeer.php
+++ b/core/lib/Thelia/Model/om/BaseResourcePeer.php
@@ -26,7 +26,7 @@ abstract class BaseResourcePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'resource';
@@ -379,6 +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();
}
/**
@@ -475,639 +481,6 @@ abstract class BaseResourcePeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupResource table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinGroupResource(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ResourcePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ResourcePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ResourcePeer::ID, GroupResourcePeer::RESOURCE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ResourceDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinResourceDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ResourcePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ResourcePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ResourcePeer::ID, ResourceDescPeer::RESOURCE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Resource objects pre-filled with their GroupResource objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Resource objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinGroupResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
- }
-
- ResourcePeer::addSelectColumns($criteria);
- $startcol = ResourcePeer::NUM_HYDRATE_COLUMNS;
- GroupResourcePeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ResourcePeer::ID, GroupResourcePeer::RESOURCE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ResourcePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ResourcePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ResourcePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ResourcePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = GroupResourcePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupResourcePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- GroupResourcePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Resource) to $obj2 (GroupResource)
- // one to one relationship
- $obj1->setGroupResource($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Resource objects pre-filled with their ResourceDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Resource objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinResourceDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
- }
-
- ResourcePeer::addSelectColumns($criteria);
- $startcol = ResourcePeer::NUM_HYDRATE_COLUMNS;
- ResourceDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(ResourcePeer::ID, ResourceDescPeer::RESOURCE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ResourcePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ResourcePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = ResourcePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ResourcePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ResourceDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ResourceDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ResourceDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ResourceDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Resource) to $obj2 (ResourceDesc)
- // one to one relationship
- $obj1->setResourceDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ResourcePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ResourcePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ResourcePeer::ID, GroupResourcePeer::RESOURCE_ID, $join_behavior);
-
- $criteria->addJoin(ResourcePeer::ID, ResourceDescPeer::RESOURCE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Resource objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Resource objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
- }
-
- ResourcePeer::addSelectColumns($criteria);
- $startcol2 = ResourcePeer::NUM_HYDRATE_COLUMNS;
-
- GroupResourcePeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + GroupResourcePeer::NUM_HYDRATE_COLUMNS;
-
- ResourceDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + ResourceDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ResourcePeer::ID, GroupResourcePeer::RESOURCE_ID, $join_behavior);
-
- $criteria->addJoin(ResourcePeer::ID, ResourceDescPeer::RESOURCE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ResourcePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ResourcePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ResourcePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ResourcePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined GroupResource rows
-
- $key2 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = GroupResourcePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupResourcePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- GroupResourcePeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Resource) to the collection in $obj2 (GroupResource)
- $obj1->setGroupResource($obj2);
- } // if joined row not null
-
- // Add objects for joined ResourceDesc rows
-
- $key3 = ResourceDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = ResourceDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = ResourceDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- ResourceDescPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Resource) to the collection in $obj3 (ResourceDesc)
- $obj1->setResourceDesc($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related GroupResource table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptGroupResource(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ResourcePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ResourcePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ResourcePeer::ID, ResourceDescPeer::RESOURCE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related ResourceDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptResourceDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(ResourcePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- ResourcePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(ResourcePeer::ID, GroupResourcePeer::RESOURCE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Resource objects pre-filled with all related objects except GroupResource.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Resource objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptGroupResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
- }
-
- ResourcePeer::addSelectColumns($criteria);
- $startcol2 = ResourcePeer::NUM_HYDRATE_COLUMNS;
-
- ResourceDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ResourceDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ResourcePeer::ID, ResourceDescPeer::RESOURCE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ResourcePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ResourcePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ResourcePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ResourcePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined ResourceDesc rows
-
- $key2 = ResourceDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ResourceDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ResourceDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ResourceDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Resource) to the collection in $obj2 (ResourceDesc)
- $obj1->setResourceDesc($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Resource objects pre-filled with all related objects except ResourceDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Resource objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptResourceDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(ResourcePeer::DATABASE_NAME);
- }
-
- ResourcePeer::addSelectColumns($criteria);
- $startcol2 = ResourcePeer::NUM_HYDRATE_COLUMNS;
-
- GroupResourcePeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + GroupResourcePeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(ResourcePeer::ID, GroupResourcePeer::RESOURCE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = ResourcePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = ResourcePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = ResourcePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- ResourcePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined GroupResource rows
-
- $key2 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = GroupResourcePeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = GroupResourcePeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- GroupResourcePeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Resource) to the collection in $obj2 (GroupResource)
- $obj1->setGroupResource($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseResourceQuery.php b/core/lib/Thelia/Model/om/BaseResourceQuery.php
index db4592b4c..9ae6f0863 100644
--- a/core/lib/Thelia/Model/om/BaseResourceQuery.php
+++ b/core/lib/Thelia/Model/om/BaseResourceQuery.php
@@ -69,7 +69,7 @@ abstract class BaseResourceQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Resource', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Resource', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -245,10 +245,6 @@ abstract class BaseResourceQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByGroupResource()
- *
- * @see filterByResourceDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -384,7 +380,7 @@ abstract class BaseResourceQuery extends ModelCriteria
/**
* Filter the query by a related GroupResource object
*
- * @param GroupResource|PropelObjectCollection $groupResource The related object(s) to use as filter
+ * @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
@@ -396,12 +392,10 @@ abstract class BaseResourceQuery extends ModelCriteria
return $this
->addUsingAlias(ResourcePeer::ID, $groupResource->getResourceId(), $comparison);
} elseif ($groupResource instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ResourcePeer::ID, $groupResource->toKeyValue('PrimaryKey', 'ResourceId'), $comparison);
+ ->useGroupResourceQuery()
+ ->filterByPrimaryKeys($groupResource->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection');
}
@@ -460,7 +454,7 @@ abstract class BaseResourceQuery extends ModelCriteria
/**
* Filter the query by a related ResourceDesc object
*
- * @param ResourceDesc|PropelObjectCollection $resourceDesc The related object(s) to use as filter
+ * @param ResourceDesc|PropelObjectCollection $resourceDesc 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
@@ -472,12 +466,10 @@ abstract class BaseResourceQuery extends ModelCriteria
return $this
->addUsingAlias(ResourcePeer::ID, $resourceDesc->getResourceId(), $comparison);
} elseif ($resourceDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(ResourcePeer::ID, $resourceDesc->toKeyValue('PrimaryKey', 'ResourceId'), $comparison);
+ ->useResourceDescQuery()
+ ->filterByPrimaryKeys($resourceDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByResourceDesc() only accepts arguments of type ResourceDesc or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseRewriting.php b/core/lib/Thelia/Model/om/BaseRewriting.php
index 929e444e8..87352cd3c 100644
--- a/core/lib/Thelia/Model/om/BaseRewriting.php
+++ b/core/lib/Thelia/Model/om/BaseRewriting.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Category;
use Thelia\Model\CategoryQuery;
@@ -104,24 +102,24 @@ abstract class BaseRewriting extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Category one-to-one related Category object
+ * @var Product
*/
- protected $singleCategory;
+ protected $aProduct;
/**
- * @var Content one-to-one related Content object
+ * @var Category
*/
- protected $singleContent;
+ protected $aCategory;
/**
- * @var Folder one-to-one related Folder object
+ * @var Folder
*/
- protected $singleFolder;
+ protected $aFolder;
/**
- * @var Product one-to-one related Product object
+ * @var Content
*/
- protected $singleProduct;
+ protected $aContent;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -137,30 +135,6 @@ abstract class BaseRewriting extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $categorysScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $contentsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $foldersScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -354,6 +328,10 @@ abstract class BaseRewriting extends BaseObject implements Persistent
$this->modifiedColumns[] = RewritingPeer::PRODUCT_ID;
}
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
return $this;
} // setProductId()
@@ -375,6 +353,10 @@ abstract class BaseRewriting extends BaseObject implements Persistent
$this->modifiedColumns[] = RewritingPeer::CATEGORY_ID;
}
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
return $this;
} // setCategoryId()
@@ -396,6 +378,10 @@ abstract class BaseRewriting extends BaseObject implements Persistent
$this->modifiedColumns[] = RewritingPeer::FOLDER_ID;
}
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
return $this;
} // setFolderId()
@@ -417,6 +403,10 @@ abstract class BaseRewriting extends BaseObject implements Persistent
$this->modifiedColumns[] = RewritingPeer::CONTENT_ID;
}
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
return $this;
} // setContentId()
@@ -538,6 +528,18 @@ abstract class BaseRewriting extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
} // ensureConsistency
/**
@@ -577,14 +579,10 @@ abstract class BaseRewriting extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCategory = null;
-
- $this->singleContent = null;
-
- $this->singleFolder = null;
-
- $this->singleProduct = null;
-
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aFolder = null;
+ $this->aContent = null;
} // if (deep)
}
@@ -698,6 +696,39 @@ abstract class BaseRewriting extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -709,66 +740,6 @@ abstract class BaseRewriting extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->categorysScheduledForDeletion !== null) {
- if (!$this->categorysScheduledForDeletion->isEmpty()) {
- CategoryQuery::create()
- ->filterByPrimaryKeys($this->categorysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->categorysScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->isDeleted()) {
- $affectedRows += $this->singleCategory->save($con);
- }
- }
-
- if ($this->contentsScheduledForDeletion !== null) {
- if (!$this->contentsScheduledForDeletion->isEmpty()) {
- ContentQuery::create()
- ->filterByPrimaryKeys($this->contentsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->contentsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->isDeleted()) {
- $affectedRows += $this->singleContent->save($con);
- }
- }
-
- if ($this->foldersScheduledForDeletion !== null) {
- if (!$this->foldersScheduledForDeletion->isEmpty()) {
- FolderQuery::create()
- ->filterByPrimaryKeys($this->foldersScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->foldersScheduledForDeletion = null;
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->isDeleted()) {
- $affectedRows += $this->singleFolder->save($con);
- }
- }
-
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -937,35 +908,41 @@ abstract class BaseRewriting extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if (!$this->aProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
+ }
+ }
+
+ if ($this->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+ if ($this->aFolder !== null) {
+ if (!$this->aFolder->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures());
+ }
+ }
+
+ if ($this->aContent !== null) {
+ if (!$this->aContent->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures());
+ }
+ }
+
+
if (($retval = RewritingPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCategory !== null) {
- if (!$this->singleCategory->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCategory->getValidationFailures());
- }
- }
-
- if ($this->singleContent !== null) {
- if (!$this->singleContent->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleContent->getValidationFailures());
- }
- }
-
- if ($this->singleFolder !== null) {
- if (!$this->singleFolder->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleFolder->getValidationFailures());
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -1064,17 +1041,17 @@ abstract class BaseRewriting extends BaseObject implements Persistent
$keys[7] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCategory) {
- $result['Category'] = $this->singleCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleContent) {
- $result['Content'] = $this->singleContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleFolder) {
- $result['Folder'] = $this->singleFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1263,26 +1240,6 @@ abstract class BaseRewriting extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCategory();
- if ($relObj) {
- $copyObj->setCategory($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getContent();
- if ($relObj) {
- $copyObj->setContent($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getFolder();
- if ($relObj) {
- $copyObj->setFolder($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1333,163 +1290,210 @@ abstract class BaseRewriting extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Product object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Category object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Category
- * @throws PropelException
- */
- public function getCategory(PropelPDO $con = null)
- {
-
- if ($this->singleCategory === null && !$this->isNew()) {
- $this->singleCategory = CategoryQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCategory;
- }
-
- /**
- * Sets a single Category object as related to this object by a one-to-one relationship.
- *
- * @param Category $v Category
- * @return Rewriting The current object (for fluent API support)
- * @throws PropelException
- */
- public function setCategory(Category $v = null)
- {
- $this->singleCategory = $v;
-
- // Make sure that that the passed-in Category isn't already associated with this object
- if ($v !== null && $v->getRewriting() === null) {
- $v->setRewriting($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Content object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Content
- * @throws PropelException
- */
- public function getContent(PropelPDO $con = null)
- {
-
- if ($this->singleContent === null && !$this->isNew()) {
- $this->singleContent = ContentQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleContent;
- }
-
- /**
- * Sets a single Content object as related to this object by a one-to-one relationship.
- *
- * @param Content $v Content
- * @return Rewriting The current object (for fluent API support)
- * @throws PropelException
- */
- public function setContent(Content $v = null)
- {
- $this->singleContent = $v;
-
- // Make sure that that the passed-in Content isn't already associated with this object
- if ($v !== null && $v->getRewriting() === null) {
- $v->setRewriting($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Folder object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Folder
- * @throws PropelException
- */
- public function getFolder(PropelPDO $con = null)
- {
-
- if ($this->singleFolder === null && !$this->isNew()) {
- $this->singleFolder = FolderQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleFolder;
- }
-
- /**
- * Sets a single Folder object as related to this object by a one-to-one relationship.
- *
- * @param Folder $v Folder
- * @return Rewriting The current object (for fluent API support)
- * @throws PropelException
- */
- public function setFolder(Folder $v = null)
- {
- $this->singleFolder = $v;
-
- // Make sure that that the passed-in Folder isn't already associated with this object
- if ($v !== null && $v->getRewriting() === null) {
- $v->setRewriting($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Product
- * @throws PropelException
- */
- public function getProduct(PropelPDO $con = null)
- {
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleProduct;
- }
-
- /**
- * Sets a single Product object as related to this object by a one-to-one relationship.
- *
- * @param Product $v Product
+ * @param Product $v
* @return Rewriting The current object (for fluent API support)
* @throws PropelException
*/
public function setProduct(Product $v = null)
{
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getRewriting() === null) {
- $v->setRewriting($this);
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
}
+ $this->aProduct = $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 ($v !== null) {
+ $v->addRewriting($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Product object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
+ * @throws PropelException
+ */
+ public function getProduct(PropelPDO $con = null)
+ {
+ 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->aProduct->addRewritings($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return Rewriting The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(Category $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Category object, it will not be re-added.
+ if ($v !== null) {
+ $v->addRewriting($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Category object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Category The associated Category object.
+ * @throws PropelException
+ */
+ public function getCategory(PropelPDO $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->category_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->aCategory->addRewritings($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a Folder object.
+ *
+ * @param Folder $v
+ * @return Rewriting The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(Folder $v = null)
+ {
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Folder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addRewriting($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Folder object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Folder The associated Folder object.
+ * @throws PropelException
+ */
+ public function getFolder(PropelPDO $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = FolderQuery::create()->findPk($this->folder_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->aFolder->addRewritings($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
+ /**
+ * Declares an association between this object and a Content object.
+ *
+ * @param Content $v
+ * @return Rewriting The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(Content $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Content object, it will not be re-added.
+ if ($v !== null) {
+ $v->addRewriting($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Content object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Content The associated Content object.
+ * @throws PropelException
+ */
+ public function getContent(PropelPDO $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ContentQuery::create()->findPk($this->content_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->aContent->addRewritings($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1523,36 +1527,12 @@ abstract class BaseRewriting extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCategory) {
- $this->singleCategory->clearAllReferences($deep);
- }
- if ($this->singleContent) {
- $this->singleContent->clearAllReferences($deep);
- }
- if ($this->singleFolder) {
- $this->singleFolder->clearAllReferences($deep);
- }
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCategory instanceof PropelCollection) {
- $this->singleCategory->clearIterator();
- }
- $this->singleCategory = null;
- if ($this->singleContent instanceof PropelCollection) {
- $this->singleContent->clearIterator();
- }
- $this->singleContent = null;
- if ($this->singleFolder instanceof PropelCollection) {
- $this->singleFolder->clearIterator();
- }
- $this->singleFolder = null;
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aFolder = null;
+ $this->aContent = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseRewritingPeer.php b/core/lib/Thelia/Model/om/BaseRewritingPeer.php
index 464917144..c935e9c26 100644
--- a/core/lib/Thelia/Model/om/BaseRewritingPeer.php
+++ b/core/lib/Thelia/Model/om/BaseRewritingPeer.php
@@ -28,7 +28,7 @@ abstract class BaseRewritingPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'rewriting';
@@ -401,18 +401,6 @@ abstract class BaseRewritingPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CategoryPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CategoryPeer::clearInstancePool();
- // Invalidate objects in ContentPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ContentPeer::clearInstancePool();
- // Invalidate objects in FolderPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- FolderPeer::clearInstancePool();
- // Invalidate objects in ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
}
/**
@@ -509,6 +497,1381 @@ abstract class BaseRewritingPeer
return array($obj, $col);
}
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Rewriting 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
+ * @return array Array of Rewriting objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol = RewritingPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Rewriting) to $obj2 (Product)
+ $obj2->addRewriting($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Rewriting objects pre-filled with their Category objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Rewriting objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol = RewritingPeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Rewriting) to $obj2 (Category)
+ $obj2->addRewriting($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Rewriting objects pre-filled with their Folder objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Rewriting objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol = RewritingPeer::NUM_HYDRATE_COLUMNS;
+ FolderPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = FolderPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ FolderPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Rewriting) to $obj2 (Folder)
+ $obj2->addRewriting($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Rewriting objects pre-filled with their Content objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Rewriting objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol = RewritingPeer::NUM_HYDRATE_COLUMNS;
+ ContentPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ContentPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ContentPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Rewriting) to $obj2 (Content)
+ $obj2->addRewriting($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of Rewriting objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Rewriting objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol6 = $startcol5 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj2 (Product)
+ $obj2->addRewriting($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj3 (Category)
+ $obj3->addRewriting($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Folder rows
+
+ $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = FolderPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ FolderPeer::addInstanceToPool($obj4, $key4);
+ } // if obj4 loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj4 (Folder)
+ $obj4->addRewriting($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Content rows
+
+ $key5 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol5);
+ if ($key5 !== null) {
+ $obj5 = ContentPeer::getInstanceFromPool($key5);
+ if (!$obj5) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj5 = new $cls();
+ $obj5->hydrate($row, $startcol5);
+ ContentPeer::addInstanceToPool($obj5, $key5);
+ } // if obj5 loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj5 (Content)
+ $obj5->addRewriting($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Category table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCategory(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Folder table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptFolder(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Content table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptContent(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Rewriting objects pre-filled with all related objects except Product.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Rewriting objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Category rows
+
+ $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CategoryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CategoryPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj2 (Category)
+ $obj2->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key3 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = FolderPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ FolderPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj3 (Folder)
+ $obj3->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ContentPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ContentPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj4 (Content)
+ $obj4->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Rewriting objects pre-filled with all related objects except Category.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Rewriting objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj2 (Product)
+ $obj2->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key3 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = FolderPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ FolderPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj3 (Folder)
+ $obj3->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ContentPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ContentPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj4 (Content)
+ $obj4->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Rewriting objects pre-filled with all related objects except Folder.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Rewriting objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj2 (Product)
+ $obj2->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj3 (Category)
+ $obj3->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Content rows
+
+ $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = ContentPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = ContentPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ ContentPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj4 (Content)
+ $obj4->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Rewriting objects pre-filled with all related objects except Content.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Rewriting objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+ }
+
+ RewritingPeer::addSelectColumns($criteria);
+ $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
+
+ $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = RewritingPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj2 (Product)
+ $obj2->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Category rows
+
+ $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CategoryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CategoryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CategoryPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj3 (Category)
+ $obj3->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Folder rows
+
+ $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = FolderPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = FolderPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ FolderPeer::addInstanceToPool($obj4, $key4);
+ } // if $obj4 already loaded
+
+ // Add the $obj1 (Rewriting) to the collection in $obj4 (Folder)
+ $obj4->addRewriting($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -638,7 +2001,6 @@ abstract class BaseRewritingPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += RewritingPeer::doOnDeleteCascade(new Criteria(RewritingPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(RewritingPeer::TABLE_NAME, $con, RewritingPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -672,14 +2034,24 @@ abstract class BaseRewritingPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ RewritingPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Rewriting) { // it's a model object
+ // invalidate the cache for this single object
+ RewritingPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(RewritingPeer::DATABASE_NAME);
$criteria->add(RewritingPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ RewritingPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -692,23 +2064,6 @@ abstract class BaseRewritingPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += RewritingPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- RewritingPeer::clearInstancePool();
- } elseif ($values instanceof Rewriting) { // it's a model object
- RewritingPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- RewritingPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
RewritingPeer::clearRelatedInstancePool();
$con->commit();
@@ -720,57 +2075,6 @@ abstract class BaseRewritingPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = RewritingPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Category objects
- $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
-
- $criteria->add(CategoryPeer::ID, $obj->getCategoryId());
- $affectedRows += CategoryPeer::doDelete($criteria, $con);
-
- // delete related Content objects
- $criteria = new Criteria(ContentPeer::DATABASE_NAME);
-
- $criteria->add(ContentPeer::ID, $obj->getContentId());
- $affectedRows += ContentPeer::doDelete($criteria, $con);
-
- // delete related Folder objects
- $criteria = new Criteria(FolderPeer::DATABASE_NAME);
-
- $criteria->add(FolderPeer::ID, $obj->getFolderId());
- $affectedRows += FolderPeer::doDelete($criteria, $con);
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given Rewriting object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseRewritingQuery.php b/core/lib/Thelia/Model/om/BaseRewritingQuery.php
index 53cff7d00..e2e0c3066 100644
--- a/core/lib/Thelia/Model/om/BaseRewritingQuery.php
+++ b/core/lib/Thelia/Model/om/BaseRewritingQuery.php
@@ -47,21 +47,21 @@ use Thelia\Model\RewritingQuery;
* @method RewritingQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method RewritingQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
+ * @method RewritingQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
+ * @method RewritingQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
+ * @method RewritingQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
+ *
* @method RewritingQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
* @method RewritingQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
* @method RewritingQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation
*
- * @method RewritingQuery leftJoinContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the Content relation
- * @method RewritingQuery rightJoinContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Content relation
- * @method RewritingQuery innerJoinContent($relationAlias = null) Adds a INNER JOIN clause to the query using the Content relation
- *
* @method RewritingQuery leftJoinFolder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Folder relation
* @method RewritingQuery rightJoinFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Folder relation
* @method RewritingQuery innerJoinFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the Folder relation
*
- * @method RewritingQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
- * @method RewritingQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
- * @method RewritingQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
+ * @method RewritingQuery leftJoinContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the Content relation
+ * @method RewritingQuery rightJoinContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Content relation
+ * @method RewritingQuery innerJoinContent($relationAlias = null) Adds a INNER JOIN clause to the query using the Content relation
*
* @method Rewriting findOne(PropelPDO $con = null) Return the first Rewriting matching the query
* @method Rewriting findOneOrCreate(PropelPDO $con = null) Return the first Rewriting matching the query, or a new Rewriting object populated from the query conditions when no match is found
@@ -95,7 +95,7 @@ abstract class BaseRewritingQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Rewriting', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Rewriting', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -327,6 +327,8 @@ abstract class BaseRewritingQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProduct()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -368,6 +370,8 @@ abstract class BaseRewritingQuery extends ModelCriteria
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
*
*
+ * @see filterByCategory()
+ *
* @param mixed $categoryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -409,6 +413,8 @@ abstract class BaseRewritingQuery extends ModelCriteria
* $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
*
*
+ * @see filterByFolder()
+ *
* @param mixed $folderId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -450,6 +456,8 @@ abstract class BaseRewritingQuery extends ModelCriteria
* $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
*
*
+ * @see filterByContent()
+ *
* @param mixed $contentId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -567,232 +575,10 @@ abstract class BaseRewritingQuery extends ModelCriteria
return $this->addUsingAlias(RewritingPeer::UPDATED_AT, $updatedAt, $comparison);
}
- /**
- * Filter the query by a related Category object
- *
- * @param Category|PropelObjectCollection $category the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return RewritingQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByCategory($category, $comparison = null)
- {
- if ($category instanceof Category) {
- return $this
- ->addUsingAlias(RewritingPeer::CATEGORY_ID, $category->getId(), $comparison);
- } elseif ($category instanceof PropelObjectCollection) {
- return $this
- ->useCategoryQuery()
- ->filterByPrimaryKeys($category->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Category relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return RewritingQuery The current query, for fluid interface
- */
- public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Category');
-
- // 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, 'Category');
- }
-
- return $this;
- }
-
- /**
- * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query
- */
- public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinCategory($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
- }
-
- /**
- * Filter the query by a related Content object
- *
- * @param Content|PropelObjectCollection $content the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return RewritingQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByContent($content, $comparison = null)
- {
- if ($content instanceof Content) {
- return $this
- ->addUsingAlias(RewritingPeer::CONTENT_ID, $content->getId(), $comparison);
- } elseif ($content instanceof PropelObjectCollection) {
- return $this
- ->useContentQuery()
- ->filterByPrimaryKeys($content->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Content relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return RewritingQuery The current query, for fluid interface
- */
- public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Content');
-
- // 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, 'Content');
- }
-
- return $this;
- }
-
- /**
- * Use the Content relation Content 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\ContentQuery A secondary query class using the current class as primary query
- */
- public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinContent($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
- }
-
- /**
- * Filter the query by a related Folder object
- *
- * @param Folder|PropelObjectCollection $folder the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return RewritingQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByFolder($folder, $comparison = null)
- {
- if ($folder instanceof Folder) {
- return $this
- ->addUsingAlias(RewritingPeer::FOLDER_ID, $folder->getId(), $comparison);
- } elseif ($folder instanceof PropelObjectCollection) {
- return $this
- ->useFolderQuery()
- ->filterByPrimaryKeys($folder->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Folder relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return RewritingQuery The current query, for fluid interface
- */
- public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Folder');
-
- // 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, 'Folder');
- }
-
- return $this;
- }
-
- /**
- * Use the Folder relation Folder 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\FolderQuery A secondary query class using the current class as primary query
- */
- public function useFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinFolder($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
- }
-
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product the related object 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 RewritingQuery The current query, for fluid interface
@@ -804,10 +590,12 @@ abstract class BaseRewritingQuery extends ModelCriteria
return $this
->addUsingAlias(RewritingPeer::PRODUCT_ID, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(RewritingPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
}
@@ -821,7 +609,7 @@ abstract class BaseRewritingQuery extends ModelCriteria
*
* @return RewritingQuery The current query, for fluid interface
*/
- public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Product');
@@ -856,13 +644,241 @@ abstract class BaseRewritingQuery extends ModelCriteria
*
* @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
*/
- public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinProduct($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
}
+ /**
+ * Filter the query by a related Category object
+ *
+ * @param Category|PropelObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof Category) {
+ return $this
+ ->addUsingAlias(RewritingPeer::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(RewritingPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // 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, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related Folder object
+ *
+ * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof Folder) {
+ return $this
+ ->addUsingAlias(RewritingPeer::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(RewritingPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // 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, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder 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\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
+ /**
+ * Filter the query by a related Content object
+ *
+ * @param Content|PropelObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof Content) {
+ return $this
+ ->addUsingAlias(RewritingPeer::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(RewritingPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // 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, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content 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\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseStock.php b/core/lib/Thelia/Model/om/BaseStock.php
index dc44cbc18..1eb1c7c68 100644
--- a/core/lib/Thelia/Model/om/BaseStock.php
+++ b/core/lib/Thelia/Model/om/BaseStock.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Combination;
use Thelia\Model\CombinationQuery;
@@ -94,14 +92,14 @@ abstract class BaseStock extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Combination one-to-one related Combination object
+ * @var Combination
*/
- protected $singleCombination;
+ protected $aCombination;
/**
- * @var Product one-to-one related Product object
+ * @var Product
*/
- protected $singleProduct;
+ protected $aProduct;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -117,18 +115,6 @@ abstract class BaseStock extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $combinationsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $productsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -291,6 +277,10 @@ abstract class BaseStock extends BaseObject implements Persistent
$this->modifiedColumns[] = StockPeer::COMBINATION_ID;
}
+ if ($this->aCombination !== null && $this->aCombination->getId() !== $v) {
+ $this->aCombination = null;
+ }
+
return $this;
} // setCombinationId()
@@ -312,6 +302,10 @@ abstract class BaseStock extends BaseObject implements Persistent
$this->modifiedColumns[] = StockPeer::PRODUCT_ID;
}
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
return $this;
} // setProductId()
@@ -474,6 +468,12 @@ abstract class BaseStock extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aCombination !== null && $this->combination_id !== $this->aCombination->getId()) {
+ $this->aCombination = null;
+ }
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
} // ensureConsistency
/**
@@ -513,10 +513,8 @@ abstract class BaseStock extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCombination = null;
-
- $this->singleProduct = null;
-
+ $this->aCombination = null;
+ $this->aProduct = null;
} // if (deep)
}
@@ -630,6 +628,25 @@ abstract class BaseStock extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCombination !== null) {
+ if ($this->aCombination->isModified() || $this->aCombination->isNew()) {
+ $affectedRows += $this->aCombination->save($con);
+ }
+ $this->setCombination($this->aCombination);
+ }
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -641,36 +658,6 @@ abstract class BaseStock extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->combinationsScheduledForDeletion !== null) {
- if (!$this->combinationsScheduledForDeletion->isEmpty()) {
- CombinationQuery::create()
- ->filterByPrimaryKeys($this->combinationsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->combinationsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCombination !== null) {
- if (!$this->singleCombination->isDeleted()) {
- $affectedRows += $this->singleCombination->save($con);
- }
- }
-
- if ($this->productsScheduledForDeletion !== null) {
- if (!$this->productsScheduledForDeletion->isEmpty()) {
- ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->productsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->isDeleted()) {
- $affectedRows += $this->singleProduct->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -844,23 +831,29 @@ abstract class BaseStock extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCombination !== null) {
+ if (!$this->aCombination->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCombination->getValidationFailures());
+ }
+ }
+
+ if ($this->aProduct !== null) {
+ if (!$this->aProduct->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
+ }
+ }
+
+
if (($retval = StockPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCombination !== null) {
- if (!$this->singleCombination->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCombination->getValidationFailures());
- }
- }
-
- if ($this->singleProduct !== null) {
- if (!$this->singleProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleProduct->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -955,11 +948,11 @@ abstract class BaseStock extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCombination) {
- $result['Combination'] = $this->singleCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCombination) {
+ $result['Combination'] = $this->aCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleProduct) {
- $result['Product'] = $this->singleProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1142,16 +1135,6 @@ abstract class BaseStock extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCombination();
- if ($relObj) {
- $copyObj->setCombination($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1202,91 +1185,108 @@ abstract class BaseStock extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Combination object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Combination object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Combination
- * @throws PropelException
- */
- public function getCombination(PropelPDO $con = null)
- {
-
- if ($this->singleCombination === null && !$this->isNew()) {
- $this->singleCombination = CombinationQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCombination;
- }
-
- /**
- * Sets a single Combination object as related to this object by a one-to-one relationship.
- *
- * @param Combination $v Combination
+ * @param Combination $v
* @return Stock The current object (for fluent API support)
* @throws PropelException
*/
public function setCombination(Combination $v = null)
{
- $this->singleCombination = $v;
-
- // Make sure that that the passed-in Combination isn't already associated with this object
- if ($v !== null && $v->getStock() === null) {
- $v->setStock($this);
+ if ($v === null) {
+ $this->setCombinationId(NULL);
+ } else {
+ $this->setCombinationId($v->getId());
}
+ $this->aCombination = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Combination object, it will not be re-added.
+ if ($v !== null) {
+ $v->addStock($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single Product object, which is related to this object by a one-to-one relationship.
+ * Get the associated Combination object
*
- * @param PropelPDO $con optional connection object
- * @return Product
+ * @param PropelPDO $con Optional Connection object.
+ * @return Combination The associated Combination object.
* @throws PropelException
*/
- public function getProduct(PropelPDO $con = null)
+ public function getCombination(PropelPDO $con = null)
{
-
- if ($this->singleProduct === null && !$this->isNew()) {
- $this->singleProduct = ProductQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aCombination === null && ($this->combination_id !== null)) {
+ $this->aCombination = CombinationQuery::create()->findPk($this->combination_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->aCombination->addStocks($this);
+ */
}
- return $this->singleProduct;
+ return $this->aCombination;
}
/**
- * Sets a single Product object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a Product object.
*
- * @param Product $v Product
+ * @param Product $v
* @return Stock The current object (for fluent API support)
* @throws PropelException
*/
public function setProduct(Product $v = null)
{
- $this->singleProduct = $v;
-
- // Make sure that that the passed-in Product isn't already associated with this object
- if ($v !== null && $v->getStock() === null) {
- $v->setStock($this);
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
}
+ $this->aProduct = $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 ($v !== null) {
+ $v->addStock($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Product object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
+ * @throws PropelException
+ */
+ public function getProduct(PropelPDO $con = null)
+ {
+ 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->aProduct->addStocks($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1319,22 +1319,10 @@ abstract class BaseStock extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCombination) {
- $this->singleCombination->clearAllReferences($deep);
- }
- if ($this->singleProduct) {
- $this->singleProduct->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCombination instanceof PropelCollection) {
- $this->singleCombination->clearIterator();
- }
- $this->singleCombination = null;
- if ($this->singleProduct instanceof PropelCollection) {
- $this->singleProduct->clearIterator();
- }
- $this->singleProduct = null;
+ $this->aCombination = null;
+ $this->aProduct = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseStockPeer.php b/core/lib/Thelia/Model/om/BaseStockPeer.php
index 003699eb0..c8fcb2e8f 100644
--- a/core/lib/Thelia/Model/om/BaseStockPeer.php
+++ b/core/lib/Thelia/Model/om/BaseStockPeer.php
@@ -26,7 +26,7 @@ abstract class BaseStockPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'stock';
@@ -394,12 +394,6 @@ abstract class BaseStockPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CombinationPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CombinationPeer::clearInstancePool();
- // Invalidate objects in ProductPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductPeer::clearInstancePool();
}
/**
@@ -496,6 +490,637 @@ abstract class BaseStockPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Combination table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCombination(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(StockPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ StockPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(StockPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ StockPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Stock objects pre-filled with their Combination objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Stock objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+ }
+
+ StockPeer::addSelectColumns($criteria);
+ $startcol = StockPeer::NUM_HYDRATE_COLUMNS;
+ CombinationPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = StockPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ StockPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CombinationPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CombinationPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CombinationPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Stock) to $obj2 (Combination)
+ $obj2->addStock($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Stock 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
+ * @return array Array of Stock objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+ }
+
+ StockPeer::addSelectColumns($criteria);
+ $startcol = StockPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = StockPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ StockPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Stock) to $obj2 (Product)
+ $obj2->addStock($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(StockPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ StockPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of Stock objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Stock objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+ }
+
+ StockPeer::addSelectColumns($criteria);
+ $startcol2 = StockPeer::NUM_HYDRATE_COLUMNS;
+
+ CombinationPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = StockPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ StockPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Combination rows
+
+ $key2 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CombinationPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CombinationPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CombinationPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (Stock) to the collection in $obj2 (Combination)
+ $obj2->addStock($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Product rows
+
+ $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = ProductPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ ProductPeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (Stock) to the collection in $obj3 (Product)
+ $obj3->addStock($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Combination table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCombination(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(StockPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ StockPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @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)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(StockPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ StockPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of Stock objects pre-filled with all related objects except Combination.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Stock objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+ }
+
+ StockPeer::addSelectColumns($criteria);
+ $startcol2 = StockPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = StockPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ StockPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Product rows
+
+ $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ProductPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ProductPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ProductPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Stock) to the collection in $obj2 (Product)
+ $obj2->addStock($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Stock objects pre-filled with all related objects except Product.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of Stock objects.
+ * @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)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+ }
+
+ StockPeer::addSelectColumns($criteria);
+ $startcol2 = StockPeer::NUM_HYDRATE_COLUMNS;
+
+ CombinationPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CombinationPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = StockPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ StockPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Combination rows
+
+ $key2 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CombinationPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CombinationPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CombinationPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (Stock) to the collection in $obj2 (Combination)
+ $obj2->addStock($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -629,8 +1254,6 @@ abstract class BaseStockPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += StockPeer::doOnDeleteCascade(new Criteria(StockPeer::DATABASE_NAME), $con);
- StockPeer::doOnDeleteSetNull(new Criteria(StockPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(StockPeer::TABLE_NAME, $con, StockPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +1287,24 @@ abstract class BaseStockPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ StockPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof Stock) { // it's a model object
+ // invalidate the cache for this single object
+ StockPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(StockPeer::DATABASE_NAME);
$criteria->add(StockPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ StockPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,27 +1317,6 @@ abstract class BaseStockPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += StockPeer::doOnDeleteCascade($c, $con);
-
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- StockPeer::doOnDeleteSetNull($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- StockPeer::clearInstancePool();
- } elseif ($values instanceof Stock) { // it's a model object
- StockPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- StockPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
StockPeer::clearRelatedInstancePool();
$con->commit();
@@ -716,70 +1328,6 @@ abstract class BaseStockPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = StockPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Product objects
- $criteria = new Criteria(ProductPeer::DATABASE_NAME);
-
- $criteria->add(ProductPeer::ID, $obj->getProductId());
- $affectedRows += ProductPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
- /**
- * This is a method for emulating ON DELETE SET NULL DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return void
- */
- protected static function doOnDeleteSetNull(Criteria $criteria, PropelPDO $con)
- {
-
- // first find the objects that are implicated by the $criteria
- $objects = StockPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
- // set fkey col in related Combination rows to null
- $selectCriteria = new Criteria(StockPeer::DATABASE_NAME);
- $updateValues = new Criteria(StockPeer::DATABASE_NAME);
- $selectCriteria->add(CombinationPeer::ID, $obj->getCombinationId());
- $updateValues->add(CombinationPeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- }
- }
-
/**
* Validates all modified columns of given Stock object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseStockQuery.php b/core/lib/Thelia/Model/om/BaseStockQuery.php
index f9b8c2d73..916de2f0f 100644
--- a/core/lib/Thelia/Model/om/BaseStockQuery.php
+++ b/core/lib/Thelia/Model/om/BaseStockQuery.php
@@ -81,7 +81,7 @@ abstract class BaseStockQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Stock', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Stock', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -284,6 +284,8 @@ abstract class BaseStockQuery extends ModelCriteria
* $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12
*
*
+ * @see filterByCombination()
+ *
* @param mixed $combinationId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -325,6 +327,8 @@ abstract class BaseStockQuery extends ModelCriteria
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
*
*
+ * @see filterByProduct()
+ *
* @param mixed $productId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -527,7 +531,7 @@ abstract class BaseStockQuery extends ModelCriteria
/**
* Filter the query by a related Combination object
*
- * @param Combination|PropelObjectCollection $combination the related object to use as filter
+ * @param Combination|PropelObjectCollection $combination The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return StockQuery The current query, for fluid interface
@@ -539,10 +543,12 @@ abstract class BaseStockQuery extends ModelCriteria
return $this
->addUsingAlias(StockPeer::COMBINATION_ID, $combination->getId(), $comparison);
} elseif ($combination instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useCombinationQuery()
- ->filterByPrimaryKeys($combination->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(StockPeer::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCombination() only accepts arguments of type Combination or PropelCollection');
}
@@ -556,7 +562,7 @@ abstract class BaseStockQuery extends ModelCriteria
*
* @return StockQuery The current query, for fluid interface
*/
- public function joinCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinCombination($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Combination');
@@ -591,7 +597,7 @@ abstract class BaseStockQuery extends ModelCriteria
*
* @return \Thelia\Model\CombinationQuery A secondary query class using the current class as primary query
*/
- public function useCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useCombinationQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinCombination($relationAlias, $joinType)
@@ -601,7 +607,7 @@ abstract class BaseStockQuery extends ModelCriteria
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product the related object 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 StockQuery The current query, for fluid interface
@@ -613,10 +619,12 @@ abstract class BaseStockQuery extends ModelCriteria
return $this
->addUsingAlias(StockPeer::PRODUCT_ID, $product->getId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useProductQuery()
- ->filterByPrimaryKeys($product->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(StockPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseTax.php b/core/lib/Thelia/Model/om/BaseTax.php
index 6055e96b8..88132e987 100644
--- a/core/lib/Thelia/Model/om/BaseTax.php
+++ b/core/lib/Thelia/Model/om/BaseTax.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Tax;
use Thelia\Model\TaxDesc;
@@ -74,14 +76,16 @@ abstract class BaseTax extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var TaxDesc
+ * @var PropelObjectCollection|TaxDesc[] Collection to store aggregation of TaxDesc objects.
*/
- protected $aTaxDesc;
+ protected $collTaxDescs;
+ protected $collTaxDescsPartial;
/**
- * @var TaxRuleCountry
+ * @var PropelObjectCollection|TaxRuleCountry[] Collection to store aggregation of TaxRuleCountry objects.
*/
- protected $aTaxRuleCountry;
+ protected $collTaxRuleCountrys;
+ protected $collTaxRuleCountrysPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -97,6 +101,18 @@ abstract class BaseTax extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $taxDescsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $taxRuleCountrysScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -208,14 +224,6 @@ abstract class BaseTax extends BaseObject implements Persistent
$this->modifiedColumns[] = TaxPeer::ID;
}
- if ($this->aTaxDesc !== null && $this->aTaxDesc->getTaxId() !== $v) {
- $this->aTaxDesc = null;
- }
-
- if ($this->aTaxRuleCountry !== null && $this->aTaxRuleCountry->getTaxId() !== $v) {
- $this->aTaxRuleCountry = null;
- }
-
return $this;
} // setId()
@@ -354,12 +362,6 @@ abstract class BaseTax extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aTaxDesc !== null && $this->id !== $this->aTaxDesc->getTaxId()) {
- $this->aTaxDesc = null;
- }
- if ($this->aTaxRuleCountry !== null && $this->id !== $this->aTaxRuleCountry->getTaxId()) {
- $this->aTaxRuleCountry = null;
- }
} // ensureConsistency
/**
@@ -399,8 +401,10 @@ abstract class BaseTax extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aTaxDesc = null;
- $this->aTaxRuleCountry = null;
+ $this->collTaxDescs = null;
+
+ $this->collTaxRuleCountrys = null;
+
} // if (deep)
}
@@ -514,25 +518,6 @@ abstract class BaseTax extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aTaxDesc !== null) {
- if ($this->aTaxDesc->isModified() || $this->aTaxDesc->isNew()) {
- $affectedRows += $this->aTaxDesc->save($con);
- }
- $this->setTaxDesc($this->aTaxDesc);
- }
-
- if ($this->aTaxRuleCountry !== null) {
- if ($this->aTaxRuleCountry->isModified() || $this->aTaxRuleCountry->isNew()) {
- $affectedRows += $this->aTaxRuleCountry->save($con);
- }
- $this->setTaxRuleCountry($this->aTaxRuleCountry);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -544,6 +529,41 @@ abstract class BaseTax extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->taxDescsScheduledForDeletion !== null) {
+ if (!$this->taxDescsScheduledForDeletion->isEmpty()) {
+ TaxDescQuery::create()
+ ->filterByPrimaryKeys($this->taxDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->taxDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collTaxDescs !== null) {
+ foreach ($this->collTaxDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ 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;
}
@@ -699,29 +719,27 @@ abstract class BaseTax extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aTaxDesc !== null) {
- if (!$this->aTaxDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aTaxDesc->getValidationFailures());
- }
- }
-
- if ($this->aTaxRuleCountry !== null) {
- if (!$this->aTaxRuleCountry->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aTaxRuleCountry->getValidationFailures());
- }
- }
-
-
if (($retval = TaxPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collTaxDescs !== null) {
+ foreach ($this->collTaxDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collTaxRuleCountrys !== null) {
+ foreach ($this->collTaxRuleCountrys as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -804,11 +822,11 @@ abstract class BaseTax extends BaseObject implements Persistent
$keys[3] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aTaxDesc) {
- $result['TaxDesc'] = $this->aTaxDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collTaxDescs) {
+ $result['TaxDescs'] = $this->collTaxDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aTaxRuleCountry) {
- $result['TaxRuleCountry'] = $this->aTaxRuleCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collTaxRuleCountrys) {
+ $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -973,14 +991,16 @@ abstract class BaseTax extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getTaxDesc();
- if ($relObj) {
- $copyObj->setTaxDesc($relObj->copy($deepCopy));
+ foreach ($this->getTaxDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxDesc($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getTaxRuleCountry();
- if ($relObj) {
- $copyObj->setTaxRuleCountry($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
@@ -1033,98 +1053,487 @@ abstract class BaseTax extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a TaxDesc object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param TaxDesc $v
- * @return Tax The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('TaxDesc' == $relationName) {
+ $this->initTaxDescs();
+ }
+ if ('TaxRuleCountry' == $relationName) {
+ $this->initTaxRuleCountrys();
+ }
+ }
+
+ /**
+ * Clears out the collTaxDescs 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 addTaxDescs()
+ */
+ public function clearTaxDescs()
+ {
+ $this->collTaxDescs = null; // important to set this to null since that means it is uninitialized
+ $this->collTaxDescsPartial = null;
+ }
+
+ /**
+ * reset is the collTaxDescs collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialTaxDescs($v = true)
+ {
+ $this->collTaxDescsPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxDescs collection.
+ *
+ * By default this just sets the collTaxDescs collection to an empty array (like clearcollTaxDescs());
+ * 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 initTaxDescs($overrideExisting = true)
+ {
+ if (null !== $this->collTaxDescs && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxDescs = new PropelObjectCollection();
+ $this->collTaxDescs->setModel('TaxDesc');
+ }
+
+ /**
+ * Gets an array of TaxDesc 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 Tax 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|TaxDesc[] List of TaxDesc objects
* @throws PropelException
*/
- public function setTaxDesc(TaxDesc $v = null)
+ public function getTaxDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collTaxDescsPartial && !$this->isNew();
+ if (null === $this->collTaxDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxDescs) {
+ // return empty collection
+ $this->initTaxDescs();
+ } else {
+ $collTaxDescs = TaxDescQuery::create(null, $criteria)
+ ->filterByTax($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collTaxDescsPartial && count($collTaxDescs)) {
+ $this->initTaxDescs(false);
+
+ foreach($collTaxDescs as $obj) {
+ if (false == $this->collTaxDescs->contains($obj)) {
+ $this->collTaxDescs->append($obj);
+ }
+ }
+
+ $this->collTaxDescsPartial = true;
+ }
+
+ return $collTaxDescs;
+ }
+
+ if($partial && $this->collTaxDescs) {
+ foreach($this->collTaxDescs as $obj) {
+ if($obj->isNew()) {
+ $collTaxDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxDescs = $collTaxDescs;
+ $this->collTaxDescsPartial = false;
+ }
+ }
+
+ return $this->collTaxDescs;
+ }
+
+ /**
+ * Sets a collection of TaxDesc 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 $taxDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setTaxDescs(PropelCollection $taxDescs, PropelPDO $con = null)
+ {
+ $this->taxDescsScheduledForDeletion = $this->getTaxDescs(new Criteria(), $con)->diff($taxDescs);
+
+ foreach ($this->taxDescsScheduledForDeletion as $taxDescRemoved) {
+ $taxDescRemoved->setTax(null);
+ }
+
+ $this->collTaxDescs = null;
+ foreach ($taxDescs as $taxDesc) {
+ $this->addTaxDesc($taxDesc);
+ }
+
+ $this->collTaxDescs = $taxDescs;
+ $this->collTaxDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related TaxDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related TaxDesc objects.
+ * @throws PropelException
+ */
+ public function countTaxDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collTaxDescsPartial && !$this->isNew();
+ if (null === $this->collTaxDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getTaxDescs());
+ }
+ $query = TaxDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTax($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getTaxId());
+ return count($this->collTaxDescs);
}
+ }
- $this->aTaxDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setTax($this);
+ /**
+ * Method called to associate a TaxDesc object to this object
+ * through the TaxDesc foreign key attribute.
+ *
+ * @param TaxDesc $l TaxDesc
+ * @return Tax The current object (for fluent API support)
+ */
+ public function addTaxDesc(TaxDesc $l)
+ {
+ if ($this->collTaxDescs === null) {
+ $this->initTaxDescs();
+ $this->collTaxDescsPartial = true;
+ }
+ if (!$this->collTaxDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxDesc($l);
}
-
return $this;
}
-
/**
- * Get the associated TaxDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return TaxDesc The associated TaxDesc object.
- * @throws PropelException
+ * @param TaxDesc $taxDesc The taxDesc object to add.
*/
- public function getTaxDesc(PropelPDO $con = null)
+ protected function doAddTaxDesc($taxDesc)
{
- if ($this->aTaxDesc === null && ($this->id !== null)) {
- $this->aTaxDesc = TaxDescQuery::create()
- ->filterByTax($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aTaxDesc->setTax($this);
- }
-
- return $this->aTaxDesc;
+ $this->collTaxDescs[]= $taxDesc;
+ $taxDesc->setTax($this);
}
/**
- * Declares an association between this object and a TaxRuleCountry object.
+ * @param TaxDesc $taxDesc The taxDesc object to remove.
+ */
+ public function removeTaxDesc($taxDesc)
+ {
+ if ($this->getTaxDescs()->contains($taxDesc)) {
+ $this->collTaxDescs->remove($this->collTaxDescs->search($taxDesc));
+ if (null === $this->taxDescsScheduledForDeletion) {
+ $this->taxDescsScheduledForDeletion = clone $this->collTaxDescs;
+ $this->taxDescsScheduledForDeletion->clear();
+ }
+ $this->taxDescsScheduledForDeletion[]= $taxDesc;
+ $taxDesc->setTax(null);
+ }
+ }
+
+ /**
+ * Clears out the collTaxRuleCountrys collection
*
- * @param TaxRuleCountry $v
- * @return Tax The current object (for fluent API support)
+ * 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 addTaxRuleCountrys()
+ */
+ public function clearTaxRuleCountrys()
+ {
+ $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized
+ $this->collTaxRuleCountrysPartial = null;
+ }
+
+ /**
+ * reset is the collTaxRuleCountrys collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialTaxRuleCountrys($v = true)
+ {
+ $this->collTaxRuleCountrysPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxRuleCountrys collection.
+ *
+ * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys());
+ * 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 initTaxRuleCountrys($overrideExisting = true)
+ {
+ if (null !== $this->collTaxRuleCountrys && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxRuleCountrys = new PropelObjectCollection();
+ $this->collTaxRuleCountrys->setModel('TaxRuleCountry');
+ }
+
+ /**
+ * Gets an array of TaxRuleCountry 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 Tax 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|TaxRuleCountry[] List of TaxRuleCountry objects
* @throws PropelException
*/
- public function setTaxRuleCountry(TaxRuleCountry $v = null)
+ public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collTaxRuleCountrysPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountrys) {
+ // return empty collection
+ $this->initTaxRuleCountrys();
+ } else {
+ $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria)
+ ->filterByTax($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) {
+ $this->initTaxRuleCountrys(false);
+
+ foreach($collTaxRuleCountrys as $obj) {
+ if (false == $this->collTaxRuleCountrys->contains($obj)) {
+ $this->collTaxRuleCountrys->append($obj);
+ }
+ }
+
+ $this->collTaxRuleCountrysPartial = true;
+ }
+
+ return $collTaxRuleCountrys;
+ }
+
+ if($partial && $this->collTaxRuleCountrys) {
+ foreach($this->collTaxRuleCountrys as $obj) {
+ if($obj->isNew()) {
+ $collTaxRuleCountrys[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxRuleCountrys = $collTaxRuleCountrys;
+ $this->collTaxRuleCountrysPartial = false;
+ }
+ }
+
+ return $this->collTaxRuleCountrys;
+ }
+
+ /**
+ * Sets a collection of TaxRuleCountry 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 $taxRuleCountrys A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null)
+ {
+ $this->taxRuleCountrysScheduledForDeletion = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys);
+
+ foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountryRemoved) {
+ $taxRuleCountryRemoved->setTax(null);
+ }
+
+ $this->collTaxRuleCountrys = null;
+ foreach ($taxRuleCountrys as $taxRuleCountry) {
+ $this->addTaxRuleCountry($taxRuleCountry);
+ }
+
+ $this->collTaxRuleCountrys = $taxRuleCountrys;
+ $this->collTaxRuleCountrysPartial = false;
+ }
+
+ /**
+ * Returns the number of related TaxRuleCountry objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related TaxRuleCountry objects.
+ * @throws PropelException
+ */
+ public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collTaxRuleCountrysPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountrys) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getTaxRuleCountrys());
+ }
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTax($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getTaxId());
+ return count($this->collTaxRuleCountrys);
}
+ }
- $this->aTaxRuleCountry = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setTax($this);
+ /**
+ * Method called to associate a TaxRuleCountry object to this object
+ * through the TaxRuleCountry foreign key attribute.
+ *
+ * @param TaxRuleCountry $l TaxRuleCountry
+ * @return Tax The current object (for fluent API support)
+ */
+ public function addTaxRuleCountry(TaxRuleCountry $l)
+ {
+ if ($this->collTaxRuleCountrys === null) {
+ $this->initTaxRuleCountrys();
+ $this->collTaxRuleCountrysPartial = true;
+ }
+ if (!$this->collTaxRuleCountrys->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxRuleCountry($l);
}
-
return $this;
}
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add.
+ */
+ protected function doAddTaxRuleCountry($taxRuleCountry)
+ {
+ $this->collTaxRuleCountrys[]= $taxRuleCountry;
+ $taxRuleCountry->setTax($this);
+ }
/**
- * Get the associated TaxRuleCountry object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return TaxRuleCountry The associated TaxRuleCountry object.
- * @throws PropelException
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove.
*/
- public function getTaxRuleCountry(PropelPDO $con = null)
+ public function removeTaxRuleCountry($taxRuleCountry)
{
- if ($this->aTaxRuleCountry === null && ($this->id !== null)) {
- $this->aTaxRuleCountry = TaxRuleCountryQuery::create()
- ->filterByTax($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aTaxRuleCountry->setTax($this);
+ if ($this->getTaxRuleCountrys()->contains($taxRuleCountry)) {
+ $this->collTaxRuleCountrys->remove($this->collTaxRuleCountrys->search($taxRuleCountry));
+ if (null === $this->taxRuleCountrysScheduledForDeletion) {
+ $this->taxRuleCountrysScheduledForDeletion = clone $this->collTaxRuleCountrys;
+ $this->taxRuleCountrysScheduledForDeletion->clear();
+ }
+ $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry;
+ $taxRuleCountry->setTax(null);
}
+ }
- return $this->aTaxRuleCountry;
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Tax is new, it will return
+ * an empty collection; or if this Tax has previously
+ * been saved, it will retrieve related TaxRuleCountrys 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 Tax.
+ *
+ * @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|TaxRuleCountry[] List of TaxRuleCountry objects
+ */
+ public function getTaxRuleCountrysJoinTaxRule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('TaxRule', $join_behavior);
+
+ return $this->getTaxRuleCountrys($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Tax is new, it will return
+ * an empty collection; or if this Tax has previously
+ * been saved, it will retrieve related TaxRuleCountrys 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 Tax.
+ *
+ * @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|TaxRuleCountry[] List of TaxRuleCountry objects
+ */
+ public function getTaxRuleCountrysJoinCountry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('Country', $join_behavior);
+
+ return $this->getTaxRuleCountrys($query, $con);
}
/**
@@ -1156,10 +1565,26 @@ abstract class BaseTax extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collTaxDescs) {
+ foreach ($this->collTaxDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collTaxRuleCountrys) {
+ foreach ($this->collTaxRuleCountrys as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aTaxDesc = null;
- $this->aTaxRuleCountry = null;
+ if ($this->collTaxDescs instanceof PropelCollection) {
+ $this->collTaxDescs->clearIterator();
+ }
+ $this->collTaxDescs = null;
+ if ($this->collTaxRuleCountrys instanceof PropelCollection) {
+ $this->collTaxRuleCountrys->clearIterator();
+ }
+ $this->collTaxRuleCountrys = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseTaxDesc.php b/core/lib/Thelia/Model/om/BaseTaxDesc.php
index bc991851c..babd76e97 100644
--- a/core/lib/Thelia/Model/om/BaseTaxDesc.php
+++ b/core/lib/Thelia/Model/om/BaseTaxDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Tax;
use Thelia\Model\TaxDesc;
@@ -92,9 +90,9 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Tax one-to-one related Tax object
+ * @var Tax
*/
- protected $singleTax;
+ protected $aTax;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -110,12 +108,6 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $taxsScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -278,6 +270,10 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = TaxDescPeer::TAX_ID;
}
+ if ($this->aTax !== null && $this->aTax->getId() !== $v) {
+ $this->aTax = null;
+ }
+
return $this;
} // setTaxId()
@@ -461,6 +457,9 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aTax !== null && $this->tax_id !== $this->aTax->getId()) {
+ $this->aTax = null;
+ }
} // ensureConsistency
/**
@@ -500,8 +499,7 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleTax = null;
-
+ $this->aTax = null;
} // if (deep)
}
@@ -615,6 +613,18 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTax !== null) {
+ if ($this->aTax->isModified() || $this->aTax->isNew()) {
+ $affectedRows += $this->aTax->save($con);
+ }
+ $this->setTax($this->aTax);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -626,21 +636,6 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->taxsScheduledForDeletion !== null) {
- if (!$this->taxsScheduledForDeletion->isEmpty()) {
- TaxQuery::create()
- ->filterByPrimaryKeys($this->taxsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->taxsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleTax !== null) {
- if (!$this->singleTax->isDeleted()) {
- $affectedRows += $this->singleTax->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -814,17 +809,23 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTax !== null) {
+ if (!$this->aTax->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aTax->getValidationFailures());
+ }
+ }
+
+
if (($retval = TaxDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleTax !== null) {
- if (!$this->singleTax->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleTax->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -919,8 +920,8 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleTax) {
- $result['Tax'] = $this->singleTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aTax) {
+ $result['Tax'] = $this->aTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1103,11 +1104,6 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getTax();
- if ($relObj) {
- $copyObj->setTax($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1158,55 +1154,57 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Tax object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Tax object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Tax
- * @throws PropelException
- */
- public function getTax(PropelPDO $con = null)
- {
-
- if ($this->singleTax === null && !$this->isNew()) {
- $this->singleTax = TaxQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleTax;
- }
-
- /**
- * Sets a single Tax object as related to this object by a one-to-one relationship.
- *
- * @param Tax $v Tax
+ * @param Tax $v
* @return TaxDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setTax(Tax $v = null)
{
- $this->singleTax = $v;
-
- // Make sure that that the passed-in Tax isn't already associated with this object
- if ($v !== null && $v->getTaxDesc() === null) {
- $v->setTaxDesc($this);
+ if ($v === null) {
+ $this->setTaxId(NULL);
+ } else {
+ $this->setTaxId($v->getId());
}
+ $this->aTax = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Tax object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated Tax object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Tax The associated Tax object.
+ * @throws PropelException
+ */
+ public function getTax(PropelPDO $con = null)
+ {
+ if ($this->aTax === null && ($this->tax_id !== null)) {
+ $this->aTax = TaxQuery::create()->findPk($this->tax_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->aTax->addTaxDescs($this);
+ */
+ }
+
+ return $this->aTax;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1239,15 +1237,9 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleTax) {
- $this->singleTax->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleTax instanceof PropelCollection) {
- $this->singleTax->clearIterator();
- }
- $this->singleTax = null;
+ $this->aTax = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseTaxDescPeer.php b/core/lib/Thelia/Model/om/BaseTaxDescPeer.php
index d030a81a4..aecfb3a76 100644
--- a/core/lib/Thelia/Model/om/BaseTaxDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseTaxDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseTaxDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'tax_desc';
@@ -393,9 +393,6 @@ abstract class BaseTaxDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in TaxPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- TaxPeer::clearInstancePool();
}
/**
@@ -492,6 +489,244 @@ abstract class BaseTaxDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Tax table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinTax(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxDescPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of TaxDesc objects pre-filled with their Tax objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinTax(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME);
+ }
+
+ TaxDescPeer::addSelectColumns($criteria);
+ $startcol = TaxDescPeer::NUM_HYDRATE_COLUMNS;
+ TaxPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(TaxDescPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = TaxDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = TaxPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ TaxPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (TaxDesc) to $obj2 (Tax)
+ $obj2->addTaxDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxDescPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of TaxDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME);
+ }
+
+ TaxDescPeer::addSelectColumns($criteria);
+ $startcol2 = TaxDescPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + TaxPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(TaxDescPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = TaxDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Tax rows
+
+ $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = TaxPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ TaxPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (TaxDesc) to the collection in $obj2 (Tax)
+ $obj2->addTaxDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -625,7 +860,6 @@ abstract class BaseTaxDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += TaxDescPeer::doOnDeleteCascade(new Criteria(TaxDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(TaxDescPeer::TABLE_NAME, $con, TaxDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -659,14 +893,24 @@ abstract class BaseTaxDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ TaxDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof TaxDesc) { // it's a model object
+ // invalidate the cache for this single object
+ TaxDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(TaxDescPeer::DATABASE_NAME);
$criteria->add(TaxDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ TaxDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -679,23 +923,6 @@ abstract class BaseTaxDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += TaxDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- TaxDescPeer::clearInstancePool();
- } elseif ($values instanceof TaxDesc) { // it's a model object
- TaxDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- TaxDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
TaxDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -707,39 +934,6 @@ abstract class BaseTaxDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = TaxDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Tax objects
- $criteria = new Criteria(TaxPeer::DATABASE_NAME);
-
- $criteria->add(TaxPeer::ID, $obj->getTaxId());
- $affectedRows += TaxPeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given TaxDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseTaxDescQuery.php b/core/lib/Thelia/Model/om/BaseTaxDescQuery.php
index a3b6c6aa8..f7c774672 100644
--- a/core/lib/Thelia/Model/om/BaseTaxDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseTaxDescQuery.php
@@ -76,7 +76,7 @@ abstract class BaseTaxDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\TaxDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\TaxDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -279,6 +279,8 @@ abstract class BaseTaxDescQuery extends ModelCriteria
* $query->filterByTaxId(array('min' => 12)); // WHERE tax_id > 12
*
*
+ * @see filterByTax()
+ *
* @param mixed $taxId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -486,7 +488,7 @@ abstract class BaseTaxDescQuery extends ModelCriteria
/**
* Filter the query by a related Tax object
*
- * @param Tax|PropelObjectCollection $tax the related object to use as filter
+ * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return TaxDescQuery The current query, for fluid interface
@@ -498,10 +500,12 @@ abstract class BaseTaxDescQuery extends ModelCriteria
return $this
->addUsingAlias(TaxDescPeer::TAX_ID, $tax->getId(), $comparison);
} elseif ($tax instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useTaxQuery()
- ->filterByPrimaryKeys($tax->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(TaxDescPeer::TAX_ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection');
}
diff --git a/core/lib/Thelia/Model/om/BaseTaxPeer.php b/core/lib/Thelia/Model/om/BaseTaxPeer.php
index aa2d07526..1615d0f4c 100644
--- a/core/lib/Thelia/Model/om/BaseTaxPeer.php
+++ b/core/lib/Thelia/Model/om/BaseTaxPeer.php
@@ -26,7 +26,7 @@ abstract class BaseTaxPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'tax';
@@ -379,6 +379,12 @@ abstract class BaseTaxPeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in TaxDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ TaxDescPeer::clearInstancePool();
+ // Invalidate objects in TaxRuleCountryPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ TaxRuleCountryPeer::clearInstancePool();
}
/**
@@ -475,639 +481,6 @@ abstract class BaseTaxPeer
return array($obj, $col);
}
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinTaxDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxPeer::ID, TaxDescPeer::TAX_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxRuleCountry table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinTaxRuleCountry(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxPeer::ID, TaxRuleCountryPeer::TAX_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Tax objects pre-filled with their TaxDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Tax objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinTaxDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
- }
-
- TaxPeer::addSelectColumns($criteria);
- $startcol = TaxPeer::NUM_HYDRATE_COLUMNS;
- TaxDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(TaxPeer::ID, TaxDescPeer::TAX_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = TaxPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = TaxDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = TaxDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- TaxDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Tax) to $obj2 (TaxDesc)
- // one to one relationship
- $obj1->setTaxDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Tax objects pre-filled with their TaxRuleCountry objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Tax objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinTaxRuleCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
- }
-
- TaxPeer::addSelectColumns($criteria);
- $startcol = TaxPeer::NUM_HYDRATE_COLUMNS;
- TaxRuleCountryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(TaxPeer::ID, TaxRuleCountryPeer::TAX_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = TaxPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxPeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = TaxRuleCountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- TaxRuleCountryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (Tax) to $obj2 (TaxRuleCountry)
- // one to one relationship
- $obj1->setTaxRuleCountry($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxPeer::ID, TaxDescPeer::TAX_ID, $join_behavior);
-
- $criteria->addJoin(TaxPeer::ID, TaxRuleCountryPeer::TAX_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of Tax objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Tax objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
- }
-
- TaxPeer::addSelectColumns($criteria);
- $startcol2 = TaxPeer::NUM_HYDRATE_COLUMNS;
-
- TaxDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + TaxDescPeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleCountryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(TaxPeer::ID, TaxDescPeer::TAX_ID, $join_behavior);
-
- $criteria->addJoin(TaxPeer::ID, TaxRuleCountryPeer::TAX_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = TaxPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined TaxDesc rows
-
- $key2 = TaxDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = TaxDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- TaxDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (Tax) to the collection in $obj2 (TaxDesc)
- $obj1->setTaxDesc($obj2);
- } // if joined row not null
-
- // Add objects for joined TaxRuleCountry rows
-
- $key3 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = TaxRuleCountryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- TaxRuleCountryPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (Tax) to the collection in $obj3 (TaxRuleCountry)
- $obj1->setTaxRuleCountry($obj3);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptTaxDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxPeer::ID, TaxRuleCountryPeer::TAX_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxRuleCountry table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptTaxRuleCountry(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxPeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxPeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxPeer::ID, TaxDescPeer::TAX_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of Tax objects pre-filled with all related objects except TaxDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Tax objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptTaxDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
- }
-
- TaxPeer::addSelectColumns($criteria);
- $startcol2 = TaxPeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleCountryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(TaxPeer::ID, TaxRuleCountryPeer::TAX_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = TaxPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined TaxRuleCountry rows
-
- $key2 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = TaxRuleCountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- TaxRuleCountryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Tax) to the collection in $obj2 (TaxRuleCountry)
- $obj1->setTaxRuleCountry($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of Tax objects pre-filled with all related objects except TaxRuleCountry.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of Tax objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptTaxRuleCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxPeer::DATABASE_NAME);
- }
-
- TaxPeer::addSelectColumns($criteria);
- $startcol2 = TaxPeer::NUM_HYDRATE_COLUMNS;
-
- TaxDescPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + TaxDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(TaxPeer::ID, TaxDescPeer::TAX_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxPeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxPeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = TaxPeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxPeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined TaxDesc rows
-
- $key2 = TaxDescPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = TaxDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- TaxDescPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (Tax) to the collection in $obj2 (TaxDesc)
- $obj1->setTaxDesc($obj2);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseTaxQuery.php b/core/lib/Thelia/Model/om/BaseTaxQuery.php
index e5b78ea47..f28d71d01 100644
--- a/core/lib/Thelia/Model/om/BaseTaxQuery.php
+++ b/core/lib/Thelia/Model/om/BaseTaxQuery.php
@@ -69,7 +69,7 @@ abstract class BaseTaxQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\Tax', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Tax', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -245,10 +245,6 @@ abstract class BaseTaxQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByTaxDesc()
- *
- * @see filterByTaxRuleCountry()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -396,7 +392,7 @@ abstract class BaseTaxQuery extends ModelCriteria
/**
* Filter the query by a related TaxDesc object
*
- * @param TaxDesc|PropelObjectCollection $taxDesc The related object(s) to use as filter
+ * @param TaxDesc|PropelObjectCollection $taxDesc the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return TaxQuery The current query, for fluid interface
@@ -408,12 +404,10 @@ abstract class BaseTaxQuery extends ModelCriteria
return $this
->addUsingAlias(TaxPeer::ID, $taxDesc->getTaxId(), $comparison);
} elseif ($taxDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(TaxPeer::ID, $taxDesc->toKeyValue('PrimaryKey', 'TaxId'), $comparison);
+ ->useTaxDescQuery()
+ ->filterByPrimaryKeys($taxDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByTaxDesc() only accepts arguments of type TaxDesc or PropelCollection');
}
@@ -472,7 +466,7 @@ abstract class BaseTaxQuery extends ModelCriteria
/**
* Filter the query by a related TaxRuleCountry object
*
- * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry The related object(s) to use as filter
+ * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return TaxQuery The current query, for fluid interface
@@ -484,12 +478,10 @@ abstract class BaseTaxQuery extends ModelCriteria
return $this
->addUsingAlias(TaxPeer::ID, $taxRuleCountry->getTaxId(), $comparison);
} elseif ($taxRuleCountry instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(TaxPeer::ID, $taxRuleCountry->toKeyValue('PrimaryKey', 'TaxId'), $comparison);
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection');
}
@@ -503,7 +495,7 @@ abstract class BaseTaxQuery extends ModelCriteria
*
* @return TaxQuery The current query, for fluid interface
*/
- public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('TaxRuleCountry');
@@ -538,7 +530,7 @@ abstract class BaseTaxQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
*/
- public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinTaxRuleCountry($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseTaxRule.php b/core/lib/Thelia/Model/om/BaseTaxRule.php
index c5d56b80b..3652824ce 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRule.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRule.php
@@ -10,8 +10,10 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
+use \PropelCollection;
use \PropelDateTime;
use \PropelException;
+use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Product;
use Thelia\Model\ProductQuery;
@@ -76,19 +78,22 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Product
+ * @var PropelObjectCollection|Product[] Collection to store aggregation of Product objects.
*/
- protected $aProduct;
+ protected $collProducts;
+ protected $collProductsPartial;
/**
- * @var TaxRuleCountry
+ * @var PropelObjectCollection|TaxRuleCountry[] Collection to store aggregation of TaxRuleCountry objects.
*/
- protected $aTaxRuleCountry;
+ protected $collTaxRuleCountrys;
+ protected $collTaxRuleCountrysPartial;
/**
- * @var TaxRuleDesc
+ * @var PropelObjectCollection|TaxRuleDesc[] Collection to store aggregation of TaxRuleDesc objects.
*/
- protected $aTaxRuleDesc;
+ protected $collTaxRuleDescs;
+ protected $collTaxRuleDescsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -104,6 +109,24 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $productsScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $taxRuleCountrysScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $taxRuleDescsScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -215,18 +238,6 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
$this->modifiedColumns[] = TaxRulePeer::ID;
}
- if ($this->aProduct !== null && $this->aProduct->getTaxRuleId() !== $v) {
- $this->aProduct = null;
- }
-
- if ($this->aTaxRuleCountry !== null && $this->aTaxRuleCountry->getTaxRuleId() !== $v) {
- $this->aTaxRuleCountry = null;
- }
-
- if ($this->aTaxRuleDesc !== null && $this->aTaxRuleDesc->getTaxRuleId() !== $v) {
- $this->aTaxRuleDesc = null;
- }
-
return $this;
} // setId()
@@ -365,15 +376,6 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
public function ensureConsistency()
{
- if ($this->aProduct !== null && $this->id !== $this->aProduct->getTaxRuleId()) {
- $this->aProduct = null;
- }
- if ($this->aTaxRuleCountry !== null && $this->id !== $this->aTaxRuleCountry->getTaxRuleId()) {
- $this->aTaxRuleCountry = null;
- }
- if ($this->aTaxRuleDesc !== null && $this->id !== $this->aTaxRuleDesc->getTaxRuleId()) {
- $this->aTaxRuleDesc = null;
- }
} // ensureConsistency
/**
@@ -413,9 +415,12 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->aProduct = null;
- $this->aTaxRuleCountry = null;
- $this->aTaxRuleDesc = null;
+ $this->collProducts = null;
+
+ $this->collTaxRuleCountrys = null;
+
+ $this->collTaxRuleDescs = null;
+
} // if (deep)
}
@@ -529,32 +534,6 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
- // We call the save method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aProduct !== null) {
- if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
- $affectedRows += $this->aProduct->save($con);
- }
- $this->setProduct($this->aProduct);
- }
-
- if ($this->aTaxRuleCountry !== null) {
- if ($this->aTaxRuleCountry->isModified() || $this->aTaxRuleCountry->isNew()) {
- $affectedRows += $this->aTaxRuleCountry->save($con);
- }
- $this->setTaxRuleCountry($this->aTaxRuleCountry);
- }
-
- if ($this->aTaxRuleDesc !== null) {
- if ($this->aTaxRuleDesc->isModified() || $this->aTaxRuleDesc->isNew()) {
- $affectedRows += $this->aTaxRuleDesc->save($con);
- }
- $this->setTaxRuleDesc($this->aTaxRuleDesc);
- }
-
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -566,6 +545,60 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
$this->resetModified();
}
+ if ($this->productsScheduledForDeletion !== null) {
+ if (!$this->productsScheduledForDeletion->isEmpty()) {
+ foreach ($this->productsScheduledForDeletion as $product) {
+ // need to save related object because we set the relation to null
+ $product->save($con);
+ }
+ $this->productsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collProducts !== null) {
+ foreach ($this->collProducts as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ 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) {
+ // need to save related object because we set the relation to null
+ $taxRuleDesc->save($con);
+ }
+ $this->taxRuleDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collTaxRuleDescs !== null) {
+ foreach ($this->collTaxRuleDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -721,35 +754,35 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
$failureMap = array();
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-
- if ($this->aProduct !== null) {
- if (!$this->aProduct->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
- }
- }
-
- if ($this->aTaxRuleCountry !== null) {
- if (!$this->aTaxRuleCountry->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aTaxRuleCountry->getValidationFailures());
- }
- }
-
- if ($this->aTaxRuleDesc !== null) {
- if (!$this->aTaxRuleDesc->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aTaxRuleDesc->getValidationFailures());
- }
- }
-
-
if (($retval = TaxRulePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
+ if ($this->collProducts !== null) {
+ foreach ($this->collProducts as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collTaxRuleCountrys !== null) {
+ foreach ($this->collTaxRuleCountrys as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collTaxRuleDescs !== null) {
+ foreach ($this->collTaxRuleDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -832,14 +865,14 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
$keys[3] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->aProduct) {
- $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collProducts) {
+ $result['Products'] = $this->collProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aTaxRuleCountry) {
- $result['TaxRuleCountry'] = $this->aTaxRuleCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collTaxRuleCountrys) {
+ $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->aTaxRuleDesc) {
- $result['TaxRuleDesc'] = $this->aTaxRuleDesc->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->collTaxRuleDescs) {
+ $result['TaxRuleDescs'] = $this->collTaxRuleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -1004,19 +1037,22 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getProduct();
- if ($relObj) {
- $copyObj->setProduct($relObj->copy($deepCopy));
+ foreach ($this->getProducts() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProduct($relObj->copy($deepCopy));
+ }
}
- $relObj = $this->getTaxRuleCountry();
- if ($relObj) {
- $copyObj->setTaxRuleCountry($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));
+ }
}
- $relObj = $this->getTaxRuleDesc();
- if ($relObj) {
- $copyObj->setTaxRuleDesc($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));
+ }
}
//unflag object copy
@@ -1069,145 +1105,697 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
return self::$peer;
}
+
/**
- * Declares an association between this object and a Product object.
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
*
- * @param Product $v
- * @return TaxRule The current object (for fluent API support)
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Product' == $relationName) {
+ $this->initProducts();
+ }
+ if ('TaxRuleCountry' == $relationName) {
+ $this->initTaxRuleCountrys();
+ }
+ if ('TaxRuleDesc' == $relationName) {
+ $this->initTaxRuleDescs();
+ }
+ }
+
+ /**
+ * Clears out the collProducts 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 addProducts()
+ */
+ public function clearProducts()
+ {
+ $this->collProducts = null; // important to set this to null since that means it is uninitialized
+ $this->collProductsPartial = null;
+ }
+
+ /**
+ * reset is the collProducts collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialProducts($v = true)
+ {
+ $this->collProductsPartial = $v;
+ }
+
+ /**
+ * Initializes the collProducts collection.
+ *
+ * By default this just sets the collProducts collection to an empty array (like clearcollProducts());
+ * 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 initProducts($overrideExisting = true)
+ {
+ if (null !== $this->collProducts && !$overrideExisting) {
+ return;
+ }
+ $this->collProducts = new PropelObjectCollection();
+ $this->collProducts->setModel('Product');
+ }
+
+ /**
+ * Gets an array of Product 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|Product[] List of Product objects
* @throws PropelException
*/
- public function setProduct(Product $v = null)
+ public function getProducts($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collProductsPartial && !$this->isNew();
+ if (null === $this->collProducts || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProducts) {
+ // return empty collection
+ $this->initProducts();
+ } else {
+ $collProducts = ProductQuery::create(null, $criteria)
+ ->filterByTaxRule($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collProductsPartial && count($collProducts)) {
+ $this->initProducts(false);
+
+ foreach($collProducts as $obj) {
+ if (false == $this->collProducts->contains($obj)) {
+ $this->collProducts->append($obj);
+ }
+ }
+
+ $this->collProductsPartial = true;
+ }
+
+ return $collProducts;
+ }
+
+ if($partial && $this->collProducts) {
+ foreach($this->collProducts as $obj) {
+ if($obj->isNew()) {
+ $collProducts[] = $obj;
+ }
+ }
+ }
+
+ $this->collProducts = $collProducts;
+ $this->collProductsPartial = false;
+ }
+ }
+
+ return $this->collProducts;
+ }
+
+ /**
+ * Sets a collection of Product 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 $products A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setProducts(PropelCollection $products, PropelPDO $con = null)
+ {
+ $this->productsScheduledForDeletion = $this->getProducts(new Criteria(), $con)->diff($products);
+
+ foreach ($this->productsScheduledForDeletion as $productRemoved) {
+ $productRemoved->setTaxRule(null);
+ }
+
+ $this->collProducts = null;
+ foreach ($products as $product) {
+ $this->addProduct($product);
+ }
+
+ $this->collProducts = $products;
+ $this->collProductsPartial = false;
+ }
+
+ /**
+ * Returns the number of related Product objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Product objects.
+ * @throws PropelException
+ */
+ public function countProducts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collProductsPartial && !$this->isNew();
+ if (null === $this->collProducts || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProducts) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getProducts());
+ }
+ $query = ProductQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTaxRule($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getTaxRuleId());
+ return count($this->collProducts);
}
+ }
- $this->aProduct = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setTaxRule($this);
+ /**
+ * Method called to associate a Product object to this object
+ * through the Product foreign key attribute.
+ *
+ * @param Product $l Product
+ * @return TaxRule The current object (for fluent API support)
+ */
+ public function addProduct(Product $l)
+ {
+ if ($this->collProducts === null) {
+ $this->initProducts();
+ $this->collProductsPartial = true;
+ }
+ if (!$this->collProducts->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddProduct($l);
}
-
return $this;
}
-
/**
- * Get the associated Product object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return Product The associated Product object.
- * @throws PropelException
+ * @param Product $product The product object to add.
*/
- public function getProduct(PropelPDO $con = null)
+ protected function doAddProduct($product)
{
- if ($this->aProduct === null && ($this->id !== null)) {
- $this->aProduct = ProductQuery::create()
- ->filterByTaxRule($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aProduct->setTaxRule($this);
- }
-
- return $this->aProduct;
+ $this->collProducts[]= $product;
+ $product->setTaxRule($this);
}
/**
- * Declares an association between this object and a TaxRuleCountry object.
+ * @param Product $product The product object to remove.
+ */
+ public function removeProduct($product)
+ {
+ if ($this->getProducts()->contains($product)) {
+ $this->collProducts->remove($this->collProducts->search($product));
+ if (null === $this->productsScheduledForDeletion) {
+ $this->productsScheduledForDeletion = clone $this->collProducts;
+ $this->productsScheduledForDeletion->clear();
+ }
+ $this->productsScheduledForDeletion[]= $product;
+ $product->setTaxRule(null);
+ }
+ }
+
+ /**
+ * Clears out the collTaxRuleCountrys collection
*
- * @param TaxRuleCountry $v
- * @return TaxRule The current object (for fluent API support)
+ * 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 addTaxRuleCountrys()
+ */
+ public function clearTaxRuleCountrys()
+ {
+ $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized
+ $this->collTaxRuleCountrysPartial = null;
+ }
+
+ /**
+ * reset is the collTaxRuleCountrys collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialTaxRuleCountrys($v = true)
+ {
+ $this->collTaxRuleCountrysPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxRuleCountrys collection.
+ *
+ * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys());
+ * 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 initTaxRuleCountrys($overrideExisting = true)
+ {
+ if (null !== $this->collTaxRuleCountrys && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxRuleCountrys = new PropelObjectCollection();
+ $this->collTaxRuleCountrys->setModel('TaxRuleCountry');
+ }
+
+ /**
+ * Gets an array of TaxRuleCountry 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|TaxRuleCountry[] List of TaxRuleCountry objects
* @throws PropelException
*/
- public function setTaxRuleCountry(TaxRuleCountry $v = null)
+ public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(NULL);
+ $partial = $this->collTaxRuleCountrysPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountrys) {
+ // return empty collection
+ $this->initTaxRuleCountrys();
+ } else {
+ $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria)
+ ->filterByTaxRule($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) {
+ $this->initTaxRuleCountrys(false);
+
+ foreach($collTaxRuleCountrys as $obj) {
+ if (false == $this->collTaxRuleCountrys->contains($obj)) {
+ $this->collTaxRuleCountrys->append($obj);
+ }
+ }
+
+ $this->collTaxRuleCountrysPartial = true;
+ }
+
+ return $collTaxRuleCountrys;
+ }
+
+ if($partial && $this->collTaxRuleCountrys) {
+ foreach($this->collTaxRuleCountrys as $obj) {
+ if($obj->isNew()) {
+ $collTaxRuleCountrys[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxRuleCountrys = $collTaxRuleCountrys;
+ $this->collTaxRuleCountrysPartial = false;
+ }
+ }
+
+ return $this->collTaxRuleCountrys;
+ }
+
+ /**
+ * Sets a collection of TaxRuleCountry 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 $taxRuleCountrys A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null)
+ {
+ $this->taxRuleCountrysScheduledForDeletion = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys);
+
+ foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountryRemoved) {
+ $taxRuleCountryRemoved->setTaxRule(null);
+ }
+
+ $this->collTaxRuleCountrys = null;
+ foreach ($taxRuleCountrys as $taxRuleCountry) {
+ $this->addTaxRuleCountry($taxRuleCountry);
+ }
+
+ $this->collTaxRuleCountrys = $taxRuleCountrys;
+ $this->collTaxRuleCountrysPartial = false;
+ }
+
+ /**
+ * Returns the number of related TaxRuleCountry objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related TaxRuleCountry objects.
+ * @throws PropelException
+ */
+ public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collTaxRuleCountrysPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountrys) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getTaxRuleCountrys());
+ }
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTaxRule($this)
+ ->count($con);
+ }
} else {
- $this->setId($v->getTaxRuleId());
+ return count($this->collTaxRuleCountrys);
}
+ }
- $this->aTaxRuleCountry = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setTaxRule($this);
+ /**
+ * Method called to associate a TaxRuleCountry object to this object
+ * through the TaxRuleCountry foreign key attribute.
+ *
+ * @param TaxRuleCountry $l TaxRuleCountry
+ * @return TaxRule The current object (for fluent API support)
+ */
+ public function addTaxRuleCountry(TaxRuleCountry $l)
+ {
+ if ($this->collTaxRuleCountrys === null) {
+ $this->initTaxRuleCountrys();
+ $this->collTaxRuleCountrysPartial = true;
+ }
+ if (!$this->collTaxRuleCountrys->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxRuleCountry($l);
}
-
return $this;
}
-
/**
- * Get the associated TaxRuleCountry object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return TaxRuleCountry The associated TaxRuleCountry object.
- * @throws PropelException
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add.
*/
- public function getTaxRuleCountry(PropelPDO $con = null)
+ protected function doAddTaxRuleCountry($taxRuleCountry)
{
- if ($this->aTaxRuleCountry === null && ($this->id !== null)) {
- $this->aTaxRuleCountry = TaxRuleCountryQuery::create()
- ->filterByTaxRule($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aTaxRuleCountry->setTaxRule($this);
- }
-
- return $this->aTaxRuleCountry;
+ $this->collTaxRuleCountrys[]= $taxRuleCountry;
+ $taxRuleCountry->setTaxRule($this);
}
/**
- * Declares an association between this object and a TaxRuleDesc object.
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove.
+ */
+ public function removeTaxRuleCountry($taxRuleCountry)
+ {
+ if ($this->getTaxRuleCountrys()->contains($taxRuleCountry)) {
+ $this->collTaxRuleCountrys->remove($this->collTaxRuleCountrys->search($taxRuleCountry));
+ if (null === $this->taxRuleCountrysScheduledForDeletion) {
+ $this->taxRuleCountrysScheduledForDeletion = clone $this->collTaxRuleCountrys;
+ $this->taxRuleCountrysScheduledForDeletion->clear();
+ }
+ $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry;
+ $taxRuleCountry->setTaxRule(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this TaxRule is new, it will return
+ * an empty collection; or if this TaxRule has previously
+ * been saved, it will retrieve related TaxRuleCountrys from storage.
*
- * @param TaxRuleDesc $v
- * @return TaxRule The current object (for fluent API support)
+ * 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 TaxRule.
+ *
+ * @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|TaxRuleCountry[] List of TaxRuleCountry objects
+ */
+ public function getTaxRuleCountrysJoinTax($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('Tax', $join_behavior);
+
+ return $this->getTaxRuleCountrys($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this TaxRule is new, it will return
+ * an empty collection; or if this TaxRule has previously
+ * been saved, it will retrieve related TaxRuleCountrys 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 TaxRule.
+ *
+ * @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|TaxRuleCountry[] List of TaxRuleCountry objects
+ */
+ public function getTaxRuleCountrysJoinCountry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = TaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('Country', $join_behavior);
+
+ 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 setTaxRuleDesc(TaxRuleDesc $v = null)
+ public function getTaxRuleDescs($criteria = null, PropelPDO $con = null)
{
- if ($v === null) {
- $this->setId(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 {
- $this->setId($v->getTaxRuleId());
+ return count($this->collTaxRuleDescs);
}
+ }
- $this->aTaxRuleDesc = $v;
-
- // Add binding for other direction of this 1:1 relationship.
- if ($v !== null) {
- $v->setTaxRule($this);
+ /**
+ * 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);
+ }
/**
- * Get the associated TaxRuleDesc object
- *
- * @param PropelPDO $con Optional Connection object.
- * @return TaxRuleDesc The associated TaxRuleDesc object.
- * @throws PropelException
+ * @param TaxRuleDesc $taxRuleDesc The taxRuleDesc object to remove.
*/
- public function getTaxRuleDesc(PropelPDO $con = null)
+ public function removeTaxRuleDesc($taxRuleDesc)
{
- if ($this->aTaxRuleDesc === null && ($this->id !== null)) {
- $this->aTaxRuleDesc = TaxRuleDescQuery::create()
- ->filterByTaxRule($this) // here
- ->findOne($con);
- // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
- $this->aTaxRuleDesc->setTaxRule($this);
+ 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);
}
-
- return $this->aTaxRuleDesc;
}
/**
@@ -1239,11 +1827,35 @@ abstract class BaseTaxRule extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collProducts) {
+ foreach ($this->collProducts as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collTaxRuleCountrys) {
+ foreach ($this->collTaxRuleCountrys as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collTaxRuleDescs) {
+ foreach ($this->collTaxRuleDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
- $this->aProduct = null;
- $this->aTaxRuleCountry = null;
- $this->aTaxRuleDesc = null;
+ if ($this->collProducts instanceof PropelCollection) {
+ $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;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php
index 15a4c739f..a510c4ba2 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\Country;
use Thelia\Model\CountryQuery;
@@ -96,19 +94,19 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var Country one-to-one related Country object
+ * @var Tax
*/
- protected $singleCountry;
+ protected $aTax;
/**
- * @var Tax one-to-one related Tax object
+ * @var TaxRule
*/
- protected $singleTax;
+ protected $aTaxRule;
/**
- * @var TaxRule one-to-one related TaxRule object
+ * @var Country
*/
- protected $singleTaxRule;
+ protected $aCountry;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -124,24 +122,6 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $countrysScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $taxsScheduledForDeletion = null;
-
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $taxRulesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -304,6 +284,10 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
$this->modifiedColumns[] = TaxRuleCountryPeer::TAX_RULE_ID;
}
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
return $this;
} // setTaxRuleId()
@@ -325,6 +309,10 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
$this->modifiedColumns[] = TaxRuleCountryPeer::COUNTRY_ID;
}
+ if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
+ $this->aCountry = null;
+ }
+
return $this;
} // setCountryId()
@@ -346,6 +334,10 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
$this->modifiedColumns[] = TaxRuleCountryPeer::TAX_ID;
}
+ if ($this->aTax !== null && $this->aTax->getId() !== $v) {
+ $this->aTax = null;
+ }
+
return $this;
} // setTaxId()
@@ -487,6 +479,15 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
+ }
+ if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
+ $this->aCountry = null;
+ }
+ if ($this->aTax !== null && $this->tax_id !== $this->aTax->getId()) {
+ $this->aTax = null;
+ }
} // ensureConsistency
/**
@@ -526,12 +527,9 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleCountry = null;
-
- $this->singleTax = null;
-
- $this->singleTaxRule = null;
-
+ $this->aTax = null;
+ $this->aTaxRule = null;
+ $this->aCountry = null;
} // if (deep)
}
@@ -645,6 +643,32 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTax !== null) {
+ if ($this->aTax->isModified() || $this->aTax->isNew()) {
+ $affectedRows += $this->aTax->save($con);
+ }
+ $this->setTax($this->aTax);
+ }
+
+ if ($this->aTaxRule !== null) {
+ if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
+ $affectedRows += $this->aTaxRule->save($con);
+ }
+ $this->setTaxRule($this->aTaxRule);
+ }
+
+ if ($this->aCountry !== null) {
+ if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
+ $affectedRows += $this->aCountry->save($con);
+ }
+ $this->setCountry($this->aCountry);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -656,51 +680,6 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->countrysScheduledForDeletion !== null) {
- if (!$this->countrysScheduledForDeletion->isEmpty()) {
- CountryQuery::create()
- ->filterByPrimaryKeys($this->countrysScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->countrysScheduledForDeletion = null;
- }
- }
-
- if ($this->singleCountry !== null) {
- if (!$this->singleCountry->isDeleted()) {
- $affectedRows += $this->singleCountry->save($con);
- }
- }
-
- if ($this->taxsScheduledForDeletion !== null) {
- if (!$this->taxsScheduledForDeletion->isEmpty()) {
- TaxQuery::create()
- ->filterByPrimaryKeys($this->taxsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->taxsScheduledForDeletion = null;
- }
- }
-
- if ($this->singleTax !== null) {
- if (!$this->singleTax->isDeleted()) {
- $affectedRows += $this->singleTax->save($con);
- }
- }
-
- if ($this->taxRulesScheduledForDeletion !== null) {
- if (!$this->taxRulesScheduledForDeletion->isEmpty()) {
- TaxRuleQuery::create()
- ->filterByPrimaryKeys($this->taxRulesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->taxRulesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleTaxRule !== null) {
- if (!$this->singleTaxRule->isDeleted()) {
- $affectedRows += $this->singleTaxRule->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -863,29 +842,35 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTax !== null) {
+ if (!$this->aTax->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aTax->getValidationFailures());
+ }
+ }
+
+ if ($this->aTaxRule !== null) {
+ if (!$this->aTaxRule->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures());
+ }
+ }
+
+ if ($this->aCountry !== null) {
+ if (!$this->aCountry->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCountry->getValidationFailures());
+ }
+ }
+
+
if (($retval = TaxRuleCountryPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleCountry !== null) {
- if (!$this->singleCountry->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleCountry->getValidationFailures());
- }
- }
-
- if ($this->singleTax !== null) {
- if (!$this->singleTax->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleTax->getValidationFailures());
- }
- }
-
- if ($this->singleTaxRule !== null) {
- if (!$this->singleTaxRule->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleTaxRule->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -980,14 +965,14 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleCountry) {
- $result['Country'] = $this->singleCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aTax) {
+ $result['Tax'] = $this->aTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleTax) {
- $result['Tax'] = $this->singleTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
- if (null !== $this->singleTaxRule) {
- $result['TaxRule'] = $this->singleTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCountry) {
+ $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1170,21 +1155,6 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getCountry();
- if ($relObj) {
- $copyObj->setCountry($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getTax();
- if ($relObj) {
- $copyObj->setTax($relObj->copy($deepCopy));
- }
-
- $relObj = $this->getTaxRule();
- if ($relObj) {
- $copyObj->setTaxRule($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1235,127 +1205,159 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a Tax object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single Country object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Country
- * @throws PropelException
- */
- public function getCountry(PropelPDO $con = null)
- {
-
- if ($this->singleCountry === null && !$this->isNew()) {
- $this->singleCountry = CountryQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleCountry;
- }
-
- /**
- * Sets a single Country object as related to this object by a one-to-one relationship.
- *
- * @param Country $v Country
- * @return TaxRuleCountry The current object (for fluent API support)
- * @throws PropelException
- */
- public function setCountry(Country $v = null)
- {
- $this->singleCountry = $v;
-
- // Make sure that that the passed-in Country isn't already associated with this object
- if ($v !== null && $v->getTaxRuleCountry() === null) {
- $v->setTaxRuleCountry($this);
- }
-
- return $this;
- }
-
- /**
- * Gets a single Tax object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return Tax
- * @throws PropelException
- */
- public function getTax(PropelPDO $con = null)
- {
-
- if ($this->singleTax === null && !$this->isNew()) {
- $this->singleTax = TaxQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleTax;
- }
-
- /**
- * Sets a single Tax object as related to this object by a one-to-one relationship.
- *
- * @param Tax $v Tax
+ * @param Tax $v
* @return TaxRuleCountry The current object (for fluent API support)
* @throws PropelException
*/
public function setTax(Tax $v = null)
{
- $this->singleTax = $v;
-
- // Make sure that that the passed-in Tax isn't already associated with this object
- if ($v !== null && $v->getTaxRuleCountry() === null) {
- $v->setTaxRuleCountry($this);
+ if ($v === null) {
+ $this->setTaxId(NULL);
+ } else {
+ $this->setTaxId($v->getId());
}
+ $this->aTax = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Tax object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxRuleCountry($this);
+ }
+
+
return $this;
}
+
/**
- * Gets a single TaxRule object, which is related to this object by a one-to-one relationship.
+ * Get the associated Tax object
*
- * @param PropelPDO $con optional connection object
- * @return TaxRule
+ * @param PropelPDO $con Optional Connection object.
+ * @return Tax The associated Tax object.
* @throws PropelException
*/
- public function getTaxRule(PropelPDO $con = null)
+ public function getTax(PropelPDO $con = null)
{
-
- if ($this->singleTaxRule === null && !$this->isNew()) {
- $this->singleTaxRule = TaxRuleQuery::create()->findPk($this->getPrimaryKey(), $con);
+ if ($this->aTax === null && ($this->tax_id !== null)) {
+ $this->aTax = TaxQuery::create()->findPk($this->tax_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->aTax->addTaxRuleCountrys($this);
+ */
}
- return $this->singleTaxRule;
+ return $this->aTax;
}
/**
- * Sets a single TaxRule object as related to this object by a one-to-one relationship.
+ * Declares an association between this object and a TaxRule object.
*
- * @param TaxRule $v TaxRule
+ * @param TaxRule $v
* @return TaxRuleCountry The current object (for fluent API support)
* @throws PropelException
*/
public function setTaxRule(TaxRule $v = null)
{
- $this->singleTaxRule = $v;
-
- // Make sure that that the passed-in TaxRule isn't already associated with this object
- if ($v !== null && $v->getTaxRuleCountry() === null) {
- $v->setTaxRuleCountry($this);
+ if ($v === null) {
+ $this->setTaxRuleId(NULL);
+ } else {
+ $this->setTaxRuleId($v->getId());
}
+ $this->aTaxRule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the TaxRule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxRuleCountry($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated TaxRule object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return TaxRule The associated TaxRule object.
+ * @throws PropelException
+ */
+ public function getTaxRule(PropelPDO $con = null)
+ {
+ if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) {
+ $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_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->aTaxRule->addTaxRuleCountrys($this);
+ */
+ }
+
+ return $this->aTaxRule;
+ }
+
+ /**
+ * Declares an association between this object and a Country object.
+ *
+ * @param Country $v
+ * @return TaxRuleCountry The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCountry(Country $v = null)
+ {
+ if ($v === null) {
+ $this->setCountryId(NULL);
+ } else {
+ $this->setCountryId($v->getId());
+ }
+
+ $this->aCountry = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the Country object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxRuleCountry($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Country object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Country The associated Country object.
+ * @throws PropelException
+ */
+ public function getCountry(PropelPDO $con = null)
+ {
+ if ($this->aCountry === null && ($this->country_id !== null)) {
+ $this->aCountry = CountryQuery::create()->findPk($this->country_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->aCountry->addTaxRuleCountrys($this);
+ */
+ }
+
+ return $this->aCountry;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1388,29 +1390,11 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleCountry) {
- $this->singleCountry->clearAllReferences($deep);
- }
- if ($this->singleTax) {
- $this->singleTax->clearAllReferences($deep);
- }
- if ($this->singleTaxRule) {
- $this->singleTaxRule->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleCountry instanceof PropelCollection) {
- $this->singleCountry->clearIterator();
- }
- $this->singleCountry = null;
- if ($this->singleTax instanceof PropelCollection) {
- $this->singleTax->clearIterator();
- }
- $this->singleTax = null;
- if ($this->singleTaxRule instanceof PropelCollection) {
- $this->singleTaxRule->clearIterator();
- }
- $this->singleTaxRule = null;
+ $this->aTax = null;
+ $this->aTaxRule = null;
+ $this->aCountry = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php
index 599297123..f068a8a8f 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php
@@ -27,7 +27,7 @@ abstract class BaseTaxRuleCountryPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'tax_rule_country';
@@ -395,15 +395,6 @@ abstract class BaseTaxRuleCountryPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in CountryPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- CountryPeer::clearInstancePool();
- // Invalidate objects in TaxPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- TaxPeer::clearInstancePool();
- // Invalidate objects in TaxRulePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- TaxRulePeer::clearInstancePool();
}
/**
@@ -500,6 +491,983 @@ abstract class BaseTaxRuleCountryPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Tax table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinTax(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related TaxRule table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinTaxRule(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Country table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCountry(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of TaxRuleCountry objects pre-filled with their Tax objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleCountry objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinTax(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+ }
+
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ $startcol = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
+ TaxPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = TaxRuleCountryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleCountryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = TaxPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ TaxPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to $obj2 (Tax)
+ $obj2->addTaxRuleCountry($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of TaxRuleCountry objects pre-filled with their TaxRule objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleCountry objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+ }
+
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ $startcol = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
+ TaxRulePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = TaxRuleCountryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleCountryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = TaxRulePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxRulePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ TaxRulePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to $obj2 (TaxRule)
+ $obj2->addTaxRuleCountry($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of TaxRuleCountry objects pre-filled with their Country objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleCountry objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+ }
+
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ $startcol = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
+ CountryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = TaxRuleCountryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleCountryPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CountryPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CountryPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CountryPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to $obj2 (Country)
+ $obj2->addTaxRuleCountry($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of TaxRuleCountry objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleCountry objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+ }
+
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ $startcol2 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + TaxPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxRulePeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + TaxRulePeer::NUM_HYDRATE_COLUMNS;
+
+ CountryPeer::addSelectColumns($criteria);
+ $startcol5 = $startcol4 + CountryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = TaxRuleCountryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleCountryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Tax rows
+
+ $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = TaxPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ TaxPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj2 (Tax)
+ $obj2->addTaxRuleCountry($obj1);
+ } // if joined row not null
+
+ // Add objects for joined TaxRule rows
+
+ $key3 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = TaxRulePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = TaxRulePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ TaxRulePeer::addInstanceToPool($obj3, $key3);
+ } // if obj3 loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj3 (TaxRule)
+ $obj3->addTaxRuleCountry($obj1);
+ } // if joined row not null
+
+ // Add objects for joined Country rows
+
+ $key4 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol4);
+ if ($key4 !== null) {
+ $obj4 = CountryPeer::getInstanceFromPool($key4);
+ if (!$obj4) {
+
+ $cls = CountryPeer::getOMClass();
+
+ $obj4 = new $cls();
+ $obj4->hydrate($row, $startcol4);
+ CountryPeer::addInstanceToPool($obj4, $key4);
+ } // if obj4 loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj4 (Country)
+ $obj4->addTaxRuleCountry($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Tax table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptTax(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related TaxRule table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptTaxRule(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related Country table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExceptCountry(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY should not affect count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of TaxRuleCountry objects pre-filled with all related objects except Tax.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleCountry objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptTax(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+ }
+
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ $startcol2 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxRulePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + TaxRulePeer::NUM_HYDRATE_COLUMNS;
+
+ CountryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CountryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = TaxRuleCountryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleCountryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined TaxRule rows
+
+ $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = TaxRulePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxRulePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ TaxRulePeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj2 (TaxRule)
+ $obj2->addTaxRuleCountry($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Country rows
+
+ $key3 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CountryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CountryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CountryPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj3 (Country)
+ $obj3->addTaxRuleCountry($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of TaxRuleCountry objects pre-filled with all related objects except TaxRule.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleCountry objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+ }
+
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ $startcol2 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + TaxPeer::NUM_HYDRATE_COLUMNS;
+
+ CountryPeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + CountryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = TaxRuleCountryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleCountryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Tax rows
+
+ $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = TaxPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ TaxPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj2 (Tax)
+ $obj2->addTaxRuleCountry($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined Country rows
+
+ $key3 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = CountryPeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = CountryPeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ CountryPeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj3 (Country)
+ $obj3->addTaxRuleCountry($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of TaxRuleCountry objects pre-filled with all related objects except Country.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleCountry objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExceptCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ // $criteria->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+ }
+
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ $startcol2 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + TaxPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxRulePeer::addSelectColumns($criteria);
+ $startcol4 = $startcol3 + TaxRulePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior);
+
+ $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = TaxRuleCountryPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleCountryPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined Tax rows
+
+ $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = TaxPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ TaxPeer::addInstanceToPool($obj2, $key2);
+ } // if $obj2 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj2 (Tax)
+ $obj2->addTaxRuleCountry($obj1);
+
+ } // if joined row is not null
+
+ // Add objects for joined TaxRule rows
+
+ $key3 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol3);
+ if ($key3 !== null) {
+ $obj3 = TaxRulePeer::getInstanceFromPool($key3);
+ if (!$obj3) {
+
+ $cls = TaxRulePeer::getOMClass();
+
+ $obj3 = new $cls();
+ $obj3->hydrate($row, $startcol3);
+ TaxRulePeer::addInstanceToPool($obj3, $key3);
+ } // if $obj3 already loaded
+
+ // Add the $obj1 (TaxRuleCountry) to the collection in $obj3 (TaxRule)
+ $obj3->addTaxRuleCountry($obj1);
+
+ } // if joined row is not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -629,8 +1597,6 @@ abstract class BaseTaxRuleCountryPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += TaxRuleCountryPeer::doOnDeleteCascade(new Criteria(TaxRuleCountryPeer::DATABASE_NAME), $con);
- TaxRuleCountryPeer::doOnDeleteSetNull(new Criteria(TaxRuleCountryPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(TaxRuleCountryPeer::TABLE_NAME, $con, TaxRuleCountryPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -664,14 +1630,24 @@ abstract class BaseTaxRuleCountryPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ TaxRuleCountryPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof TaxRuleCountry) { // it's a model object
+ // invalidate the cache for this single object
+ TaxRuleCountryPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME);
$criteria->add(TaxRuleCountryPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ TaxRuleCountryPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -684,27 +1660,6 @@ abstract class BaseTaxRuleCountryPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += TaxRuleCountryPeer::doOnDeleteCascade($c, $con);
-
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- TaxRuleCountryPeer::doOnDeleteSetNull($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- TaxRuleCountryPeer::clearInstancePool();
- } elseif ($values instanceof TaxRuleCountry) { // it's a model object
- TaxRuleCountryPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- TaxRuleCountryPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
TaxRuleCountryPeer::clearRelatedInstancePool();
$con->commit();
@@ -716,76 +1671,6 @@ abstract class BaseTaxRuleCountryPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = TaxRuleCountryPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related Country objects
- $criteria = new Criteria(CountryPeer::DATABASE_NAME);
-
- $criteria->add(CountryPeer::ID, $obj->getCountryId());
- $affectedRows += CountryPeer::doDelete($criteria, $con);
-
- // delete related TaxRule objects
- $criteria = new Criteria(TaxRulePeer::DATABASE_NAME);
-
- $criteria->add(TaxRulePeer::ID, $obj->getTaxRuleId());
- $affectedRows += TaxRulePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
- /**
- * This is a method for emulating ON DELETE SET NULL DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return void
- */
- protected static function doOnDeleteSetNull(Criteria $criteria, PropelPDO $con)
- {
-
- // first find the objects that are implicated by the $criteria
- $objects = TaxRuleCountryPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
- // set fkey col in related Tax rows to null
- $selectCriteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME);
- $updateValues = new Criteria(TaxRuleCountryPeer::DATABASE_NAME);
- $selectCriteria->add(TaxPeer::ID, $obj->getTaxId());
- $updateValues->add(TaxPeer::ID, null);
-
- BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-
- }
- }
-
/**
* Validates all modified columns of given TaxRuleCountry object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php
index 06714606a..37af55fe7 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php
@@ -44,10 +44,6 @@ use Thelia\Model\TaxRuleCountryQuery;
* @method TaxRuleCountryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method TaxRuleCountryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method TaxRuleCountryQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
- * @method TaxRuleCountryQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
- * @method TaxRuleCountryQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation
- *
* @method TaxRuleCountryQuery leftJoinTax($relationAlias = null) Adds a LEFT JOIN clause to the query using the Tax relation
* @method TaxRuleCountryQuery rightJoinTax($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Tax relation
* @method TaxRuleCountryQuery innerJoinTax($relationAlias = null) Adds a INNER JOIN clause to the query using the Tax relation
@@ -56,6 +52,10 @@ use Thelia\Model\TaxRuleCountryQuery;
* @method TaxRuleCountryQuery rightJoinTaxRule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRule relation
* @method TaxRuleCountryQuery innerJoinTaxRule($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRule relation
*
+ * @method TaxRuleCountryQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
+ * @method TaxRuleCountryQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
+ * @method TaxRuleCountryQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation
+ *
* @method TaxRuleCountry findOne(PropelPDO $con = null) Return the first TaxRuleCountry matching the query
* @method TaxRuleCountry findOneOrCreate(PropelPDO $con = null) Return the first TaxRuleCountry matching the query, or a new TaxRuleCountry object populated from the query conditions when no match is found
*
@@ -86,7 +86,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\TaxRuleCountry', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\TaxRuleCountry', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -289,6 +289,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
* $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
*
*
+ * @see filterByTaxRule()
+ *
* @param mixed $taxRuleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -330,6 +332,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
* $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
*
*
+ * @see filterByCountry()
+ *
* @param mixed $countryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -371,6 +375,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
* $query->filterByTaxId(array('min' => 12)); // WHERE tax_id > 12
*
*
+ * @see filterByTax()
+ *
* @param mixed $taxId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -529,84 +535,10 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
return $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt, $comparison);
}
- /**
- * Filter the query by a related Country object
- *
- * @param Country|PropelObjectCollection $country the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return TaxRuleCountryQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByCountry($country, $comparison = null)
- {
- if ($country instanceof Country) {
- return $this
- ->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $country->getId(), $comparison);
- } elseif ($country instanceof PropelObjectCollection) {
- return $this
- ->useCountryQuery()
- ->filterByPrimaryKeys($country->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the Country relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return TaxRuleCountryQuery The current query, for fluid interface
- */
- public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('Country');
-
- // 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, 'Country');
- }
-
- return $this;
- }
-
- /**
- * Use the Country relation Country 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\CountryQuery A secondary query class using the current class as primary query
- */
- public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinCountry($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
- }
-
/**
* Filter the query by a related Tax object
*
- * @param Tax|PropelObjectCollection $tax the related object to use as filter
+ * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return TaxRuleCountryQuery The current query, for fluid interface
@@ -618,10 +550,12 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
return $this
->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $tax->getId(), $comparison);
} elseif ($tax instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useTaxQuery()
- ->filterByPrimaryKeys($tax->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection');
}
@@ -635,7 +569,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
*
* @return TaxRuleCountryQuery The current query, for fluid interface
*/
- public function joinTax($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinTax($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Tax');
@@ -670,7 +604,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxQuery A secondary query class using the current class as primary query
*/
- public function useTaxQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useTaxQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinTax($relationAlias, $joinType)
@@ -680,7 +614,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
/**
* Filter the query by a related TaxRule object
*
- * @param TaxRule|PropelObjectCollection $taxRule the related object to use as filter
+ * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return TaxRuleCountryQuery The current query, for fluid interface
@@ -692,10 +626,12 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
return $this
->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRule->getId(), $comparison);
} elseif ($taxRule instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useTaxRuleQuery()
- ->filterByPrimaryKeys($taxRule->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection');
}
@@ -709,7 +645,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
*
* @return TaxRuleCountryQuery The current query, for fluid interface
*/
- public function joinTaxRule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('TaxRule');
@@ -744,13 +680,89 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query
*/
- public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinTaxRule($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
}
+ /**
+ * Filter the query by a related Country object
+ *
+ * @param Country|PropelObjectCollection $country The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCountry($country, $comparison = null)
+ {
+ if ($country instanceof Country) {
+ return $this
+ ->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $country->getId(), $comparison);
+ } elseif ($country instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Country relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Country');
+
+ // 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, 'Country');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Country relation Country 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\CountryQuery A secondary query class using the current class as primary query
+ */
+ public function useCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php b/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php
index 490ac62b9..fde9bb97b 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php
@@ -10,10 +10,8 @@ use \Exception;
use \PDO;
use \Persistent;
use \Propel;
-use \PropelCollection;
use \PropelDateTime;
use \PropelException;
-use \PropelObjectCollection;
use \PropelPDO;
use Thelia\Model\TaxRule;
use Thelia\Model\TaxRuleDesc;
@@ -92,9 +90,9 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
protected $updated_at;
/**
- * @var TaxRule one-to-one related TaxRule object
+ * @var TaxRule
*/
- protected $singleTaxRule;
+ protected $aTaxRule;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -110,12 +108,6 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
*/
protected $alreadyInValidation = false;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $taxRulesScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -278,6 +270,10 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
$this->modifiedColumns[] = TaxRuleDescPeer::TAX_RULE_ID;
}
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
return $this;
} // setTaxRuleId()
@@ -461,6 +457,9 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
public function ensureConsistency()
{
+ if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
+ }
} // ensureConsistency
/**
@@ -500,8 +499,7 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
- $this->singleTaxRule = null;
-
+ $this->aTaxRule = null;
} // if (deep)
}
@@ -615,6 +613,18 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTaxRule !== null) {
+ if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
+ $affectedRows += $this->aTaxRule->save($con);
+ }
+ $this->setTaxRule($this->aTaxRule);
+ }
+
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -626,21 +636,6 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
$this->resetModified();
}
- if ($this->taxRulesScheduledForDeletion !== null) {
- if (!$this->taxRulesScheduledForDeletion->isEmpty()) {
- TaxRuleQuery::create()
- ->filterByPrimaryKeys($this->taxRulesScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->taxRulesScheduledForDeletion = null;
- }
- }
-
- if ($this->singleTaxRule !== null) {
- if (!$this->singleTaxRule->isDeleted()) {
- $affectedRows += $this->singleTaxRule->save($con);
- }
- }
-
$this->alreadyInSave = false;
}
@@ -814,17 +809,23 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
$failureMap = array();
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their coresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTaxRule !== null) {
+ if (!$this->aTaxRule->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures());
+ }
+ }
+
+
if (($retval = TaxRuleDescPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
- if ($this->singleTaxRule !== null) {
- if (!$this->singleTaxRule->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->singleTaxRule->getValidationFailures());
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -919,8 +920,8 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
$keys[6] => $this->getUpdatedAt(),
);
if ($includeForeignObjects) {
- if (null !== $this->singleTaxRule) {
- $result['TaxRule'] = $this->singleTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
@@ -1103,11 +1104,6 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
// store object hash to prevent cycle
$this->startCopy = true;
- $relObj = $this->getTaxRule();
- if ($relObj) {
- $copyObj->setTaxRule($relObj->copy($deepCopy));
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1158,55 +1154,57 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
return self::$peer;
}
-
/**
- * Initializes a collection based on the name of a relation.
- * Avoids crafting an 'init[$relationName]s' method name
- * that wouldn't work when StandardEnglishPluralizer is used.
+ * Declares an association between this object and a TaxRule object.
*
- * @param string $relationName The name of the relation to initialize
- * @return void
- */
- public function initRelation($relationName)
- {
- }
-
- /**
- * Gets a single TaxRule object, which is related to this object by a one-to-one relationship.
- *
- * @param PropelPDO $con optional connection object
- * @return TaxRule
- * @throws PropelException
- */
- public function getTaxRule(PropelPDO $con = null)
- {
-
- if ($this->singleTaxRule === null && !$this->isNew()) {
- $this->singleTaxRule = TaxRuleQuery::create()->findPk($this->getPrimaryKey(), $con);
- }
-
- return $this->singleTaxRule;
- }
-
- /**
- * Sets a single TaxRule object as related to this object by a one-to-one relationship.
- *
- * @param TaxRule $v TaxRule
+ * @param TaxRule $v
* @return TaxRuleDesc The current object (for fluent API support)
* @throws PropelException
*/
public function setTaxRule(TaxRule $v = null)
{
- $this->singleTaxRule = $v;
-
- // Make sure that that the passed-in TaxRule isn't already associated with this object
- if ($v !== null && $v->getTaxRuleDesc() === null) {
- $v->setTaxRuleDesc($this);
+ if ($v === null) {
+ $this->setTaxRuleId(NULL);
+ } else {
+ $this->setTaxRuleId($v->getId());
}
+ $this->aTaxRule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the TaxRule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxRuleDesc($this);
+ }
+
+
return $this;
}
+
+ /**
+ * Get the associated TaxRule object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return TaxRule The associated TaxRule object.
+ * @throws PropelException
+ */
+ public function getTaxRule(PropelPDO $con = null)
+ {
+ if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) {
+ $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_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->aTaxRule->addTaxRuleDescs($this);
+ */
+ }
+
+ return $this->aTaxRule;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1239,15 +1237,9 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
- if ($this->singleTaxRule) {
- $this->singleTaxRule->clearAllReferences($deep);
- }
} // if ($deep)
- if ($this->singleTaxRule instanceof PropelCollection) {
- $this->singleTaxRule->clearIterator();
- }
- $this->singleTaxRule = null;
+ $this->aTaxRule = null;
}
/**
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleDescPeer.php b/core/lib/Thelia/Model/om/BaseTaxRuleDescPeer.php
index aedfa1b8b..6b7ff375d 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRuleDescPeer.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleDescPeer.php
@@ -25,7 +25,7 @@ abstract class BaseTaxRuleDescPeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'tax_rule_desc';
@@ -393,9 +393,6 @@ abstract class BaseTaxRuleDescPeer
*/
public static function clearRelatedInstancePool()
{
- // Invalidate objects in TaxRulePeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- TaxRulePeer::clearInstancePool();
}
/**
@@ -492,6 +489,244 @@ abstract class BaseTaxRuleDescPeer
return array($obj, $col);
}
+
+ /**
+ * Returns the number of rows matching criteria, joining the related TaxRule table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinTaxRule(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleDescPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of TaxRuleDesc objects pre-filled with their TaxRule objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME);
+ }
+
+ TaxRuleDescPeer::addSelectColumns($criteria);
+ $startcol = TaxRuleDescPeer::NUM_HYDRATE_COLUMNS;
+ TaxRulePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(TaxRuleDescPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = TaxRuleDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleDescPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = TaxRulePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxRulePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ TaxRulePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (TaxRuleDesc) to $obj2 (TaxRule)
+ $obj2->addTaxRuleDesc($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(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;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(TaxRuleDescPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ TaxRuleDescPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(TaxRuleDescPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of TaxRuleDesc objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of TaxRuleDesc objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME);
+ }
+
+ TaxRuleDescPeer::addSelectColumns($criteria);
+ $startcol2 = TaxRuleDescPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxRulePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + TaxRulePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(TaxRuleDescPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = TaxRuleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = TaxRuleDescPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = TaxRuleDescPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ TaxRuleDescPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined TaxRule rows
+
+ $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = TaxRulePeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = TaxRulePeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ TaxRulePeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (TaxRuleDesc) to the collection in $obj2 (TaxRule)
+ $obj2->addTaxRuleDesc($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
@@ -625,7 +860,6 @@ abstract class BaseTaxRuleDescPeer
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- $affectedRows += TaxRuleDescPeer::doOnDeleteCascade(new Criteria(TaxRuleDescPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(TaxRuleDescPeer::TABLE_NAME, $con, TaxRuleDescPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
@@ -659,14 +893,24 @@ abstract class BaseTaxRuleDescPeer
}
if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ TaxRuleDescPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof TaxRuleDesc) { // it's a model object
+ // invalidate the cache for this single object
+ TaxRuleDescPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(TaxRuleDescPeer::DATABASE_NAME);
$criteria->add(TaxRuleDescPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ TaxRuleDescPeer::removeInstanceFromPool($singleval);
+ }
}
// Set the correct dbName
@@ -679,23 +923,6 @@ abstract class BaseTaxRuleDescPeer
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
- // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
- $c = clone $criteria;
- $affectedRows += TaxRuleDescPeer::doOnDeleteCascade($c, $con);
-
- // Because this db requires some delete cascade/set null emulation, we have to
- // clear the cached instance *after* the emulation has happened (since
- // instances get re-added by the select statement contained therein).
- if ($values instanceof Criteria) {
- TaxRuleDescPeer::clearInstancePool();
- } elseif ($values instanceof TaxRuleDesc) { // it's a model object
- TaxRuleDescPeer::removeInstanceFromPool($values);
- } else { // it's a primary key, or an array of pks
- foreach ((array) $values as $singleval) {
- TaxRuleDescPeer::removeInstanceFromPool($singleval);
- }
- }
-
$affectedRows += BasePeer::doDelete($criteria, $con);
TaxRuleDescPeer::clearRelatedInstancePool();
$con->commit();
@@ -707,39 +934,6 @@ abstract class BaseTaxRuleDescPeer
}
}
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
- {
- // initialize var to track total num of affected rows
- $affectedRows = 0;
-
- // first find the objects that are implicated by the $criteria
- $objects = TaxRuleDescPeer::doSelect($criteria, $con);
- foreach ($objects as $obj) {
-
-
- // delete related TaxRule objects
- $criteria = new Criteria(TaxRulePeer::DATABASE_NAME);
-
- $criteria->add(TaxRulePeer::ID, $obj->getTaxRuleId());
- $affectedRows += TaxRulePeer::doDelete($criteria, $con);
- }
-
- return $affectedRows;
- }
-
/**
* Validates all modified columns of given TaxRuleDesc object.
* If parameter $columns is either a single column name or an array of column names
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php
index 9738791ca..98f7d5d13 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php
@@ -76,7 +76,7 @@ abstract class BaseTaxRuleDescQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\TaxRuleDesc', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\TaxRuleDesc', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -279,6 +279,8 @@ abstract class BaseTaxRuleDescQuery extends ModelCriteria
* $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
*
*
+ * @see filterByTaxRule()
+ *
* @param mixed $taxRuleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -486,7 +488,7 @@ abstract class BaseTaxRuleDescQuery extends ModelCriteria
/**
* Filter the query by a related TaxRule object
*
- * @param TaxRule|PropelObjectCollection $taxRule the related object to use as filter
+ * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return TaxRuleDescQuery The current query, for fluid interface
@@ -498,10 +500,12 @@ abstract class BaseTaxRuleDescQuery extends ModelCriteria
return $this
->addUsingAlias(TaxRuleDescPeer::TAX_RULE_ID, $taxRule->getId(), $comparison);
} elseif ($taxRule instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
return $this
- ->useTaxRuleQuery()
- ->filterByPrimaryKeys($taxRule->getPrimaryKeys())
- ->endUse();
+ ->addUsingAlias(TaxRuleDescPeer::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection');
}
@@ -515,7 +519,7 @@ abstract class BaseTaxRuleDescQuery extends ModelCriteria
*
* @return TaxRuleDescQuery The current query, for fluid interface
*/
- public function joinTaxRule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('TaxRule');
@@ -550,7 +554,7 @@ abstract class BaseTaxRuleDescQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query
*/
- public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinTaxRule($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php
index 75a165ee0..1b038414b 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php
@@ -27,7 +27,7 @@ abstract class BaseTaxRulePeer
{
/** the default database name for this class */
- const DATABASE_NAME = 'mydb';
+ const DATABASE_NAME = 'thelia';
/** the table name for this class */
const TABLE_NAME = 'tax_rule';
@@ -380,6 +380,15 @@ abstract class BaseTaxRulePeer
*/
public static function clearRelatedInstancePool()
{
+ // 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();
}
/**
@@ -476,986 +485,6 @@ abstract class BaseTaxRulePeer
return array($obj, $col);
}
-
- /**
- * 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.
- * @param PropelPDO $con
- * @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)
- {
- // we're going to modify criteria, so copy it first
- $criteria = clone $criteria;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxRulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxRulePeer::ID, ProductPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxRuleCountry table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinTaxRuleCountry(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxRulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxRuleDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinTaxRuleDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxRulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleDescPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of TaxRule 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
- * @return array Array of TaxRule objects.
- * @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)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
- }
-
- TaxRulePeer::addSelectColumns($criteria);
- $startcol = TaxRulePeer::NUM_HYDRATE_COLUMNS;
- ProductPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(TaxRulePeer::ID, ProductPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxRulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = TaxRulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxRulePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = ProductPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ProductPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- ProductPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (TaxRule) to $obj2 (Product)
- // one to one relationship
- $obj1->setProduct($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of TaxRule objects pre-filled with their TaxRuleCountry objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of TaxRule objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinTaxRuleCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
- }
-
- TaxRulePeer::addSelectColumns($criteria);
- $startcol = TaxRulePeer::NUM_HYDRATE_COLUMNS;
- TaxRuleCountryPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxRulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = TaxRulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxRulePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = TaxRuleCountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- TaxRuleCountryPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (TaxRule) to $obj2 (TaxRuleCountry)
- // one to one relationship
- $obj1->setTaxRuleCountry($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of TaxRule objects pre-filled with their TaxRuleDesc objects.
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of TaxRule objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinTaxRuleDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
- }
-
- TaxRulePeer::addSelectColumns($criteria);
- $startcol = TaxRulePeer::NUM_HYDRATE_COLUMNS;
- TaxRuleDescPeer::addSelectColumns($criteria);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleDescPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxRulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
-
- $cls = TaxRulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxRulePeer::addInstanceToPool($obj1, $key1);
- } // if $obj1 already loaded
-
- $key2 = TaxRuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
- if ($key2 !== null) {
- $obj2 = TaxRuleDescPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxRuleDescPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol);
- TaxRuleDescPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 already loaded
-
- // Add the $obj1 (TaxRule) to $obj2 (TaxRuleDesc)
- // one to one relationship
- $obj1->setTaxRuleDesc($obj2);
-
- } // if joined row was not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxRulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
-
- // Set the correct dbName
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxRulePeer::ID, ProductPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleDescPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
- /**
- * Selects a collection of TaxRule objects pre-filled with all related objects.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of TaxRule objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
- }
-
- TaxRulePeer::addSelectColumns($criteria);
- $startcol2 = TaxRulePeer::NUM_HYDRATE_COLUMNS;
-
- ProductPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleCountryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleDescPeer::addSelectColumns($criteria);
- $startcol5 = $startcol4 + TaxRuleDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(TaxRulePeer::ID, ProductPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleDescPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxRulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = TaxRulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxRulePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Product rows
-
- $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ProductPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ProductPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ProductPeer::addInstanceToPool($obj2, $key2);
- } // if obj2 loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj2 (Product)
- $obj1->setProduct($obj2);
- } // if joined row not null
-
- // Add objects for joined TaxRuleCountry rows
-
- $key3 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = TaxRuleCountryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- TaxRuleCountryPeer::addInstanceToPool($obj3, $key3);
- } // if obj3 loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj3 (TaxRuleCountry)
- $obj1->setTaxRuleCountry($obj3);
- } // if joined row not null
-
- // Add objects for joined TaxRuleDesc rows
-
- $key4 = TaxRuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol4);
- if ($key4 !== null) {
- $obj4 = TaxRuleDescPeer::getInstanceFromPool($key4);
- if (!$obj4) {
-
- $cls = TaxRuleDescPeer::getOMClass();
-
- $obj4 = new $cls();
- $obj4->hydrate($row, $startcol4);
- TaxRuleDescPeer::addInstanceToPool($obj4, $key4);
- } // if obj4 loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj4 (TaxRuleDesc)
- $obj1->setTaxRuleDesc($obj4);
- } // if joined row not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * 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.
- * @param PropelPDO $con
- * @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)
- {
- // we're going to modify criteria, so copy it first
- $criteria = clone $criteria;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxRulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleDescPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxRuleCountry table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptTaxRuleCountry(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxRulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxRulePeer::ID, ProductPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleDescPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Returns the number of rows matching criteria, joining the related TaxRuleDesc table
- *
- * @param Criteria $criteria
- * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExceptTaxRuleDesc(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;
-
- // We need to set the primary table name, since in the case that there are no WHERE columns
- // it will be impossible for the BasePeer::createSelectSql() method to determine which
- // tables go into the FROM clause.
- $criteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME);
-
- if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
- $criteria->setDistinct();
- }
-
- if (!$criteria->hasSelectClause()) {
- TaxRulePeer::addSelectColumns($criteria);
- }
-
- $criteria->clearOrderByColumns(); // ORDER BY should not affect count
-
- // Set the correct dbName
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
-
- if ($con === null) {
- $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $criteria->addJoin(TaxRulePeer::ID, ProductPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, $join_behavior);
-
- $stmt = BasePeer::doCount($criteria, $con);
-
- if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $count = (int) $row[0];
- } else {
- $count = 0; // no rows returned; we infer that means 0 matches.
- }
- $stmt->closeCursor();
-
- return $count;
- }
-
-
- /**
- * Selects a collection of TaxRule objects pre-filled with all related objects except Product.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of TaxRule objects.
- * @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)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
- }
-
- TaxRulePeer::addSelectColumns($criteria);
- $startcol2 = TaxRulePeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleCountryPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + TaxRuleDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleDescPeer::TAX_RULE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxRulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = TaxRulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxRulePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined TaxRuleCountry rows
-
- $key2 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = TaxRuleCountryPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- TaxRuleCountryPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj2 (TaxRuleCountry)
- $obj1->setTaxRuleCountry($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined TaxRuleDesc rows
-
- $key3 = TaxRuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = TaxRuleDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = TaxRuleDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- TaxRuleDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj3 (TaxRuleDesc)
- $obj1->setTaxRuleDesc($obj3);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of TaxRule objects pre-filled with all related objects except TaxRuleCountry.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of TaxRule objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptTaxRuleCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
- }
-
- TaxRulePeer::addSelectColumns($criteria);
- $startcol2 = TaxRulePeer::NUM_HYDRATE_COLUMNS;
-
- ProductPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleDescPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + TaxRuleDescPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(TaxRulePeer::ID, ProductPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleDescPeer::TAX_RULE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxRulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = TaxRulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxRulePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Product rows
-
- $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ProductPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ProductPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ProductPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj2 (Product)
- $obj1->setProduct($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined TaxRuleDesc rows
-
- $key3 = TaxRuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = TaxRuleDescPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = TaxRuleDescPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- TaxRuleDescPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj3 (TaxRuleDesc)
- $obj1->setTaxRuleDesc($obj3);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
-
- /**
- * Selects a collection of TaxRule objects pre-filled with all related objects except TaxRuleDesc.
- *
- * @param Criteria $criteria
- * @param PropelPDO $con
- * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
- * @return array Array of TaxRule objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExceptTaxRuleDesc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
- {
- $criteria = clone $criteria;
-
- // Set the correct dbName if it has not been overridden
- // $criteria->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if ($criteria->getDbName() == Propel::getDefaultDB()) {
- $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
- }
-
- TaxRulePeer::addSelectColumns($criteria);
- $startcol2 = TaxRulePeer::NUM_HYDRATE_COLUMNS;
-
- ProductPeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
-
- TaxRuleCountryPeer::addSelectColumns($criteria);
- $startcol4 = $startcol3 + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
-
- $criteria->addJoin(TaxRulePeer::ID, ProductPeer::TAX_RULE_ID, $join_behavior);
-
- $criteria->addJoin(TaxRulePeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, $join_behavior);
-
-
- $stmt = BasePeer::doSelect($criteria, $con);
- $results = array();
-
- while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
- $key1 = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0);
- if (null !== ($obj1 = TaxRulePeer::getInstanceFromPool($key1))) {
- // We no longer rehydrate the object, since this can cause data loss.
- // See http://www.propelorm.org/ticket/509
- // $obj1->hydrate($row, 0, true); // rehydrate
- } else {
- $cls = TaxRulePeer::getOMClass();
-
- $obj1 = new $cls();
- $obj1->hydrate($row);
- TaxRulePeer::addInstanceToPool($obj1, $key1);
- } // if obj1 already loaded
-
- // Add objects for joined Product rows
-
- $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
- if ($key2 !== null) {
- $obj2 = ProductPeer::getInstanceFromPool($key2);
- if (!$obj2) {
-
- $cls = ProductPeer::getOMClass();
-
- $obj2 = new $cls();
- $obj2->hydrate($row, $startcol2);
- ProductPeer::addInstanceToPool($obj2, $key2);
- } // if $obj2 already loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj2 (Product)
- $obj1->setProduct($obj2);
-
- } // if joined row is not null
-
- // Add objects for joined TaxRuleCountry rows
-
- $key3 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol3);
- if ($key3 !== null) {
- $obj3 = TaxRuleCountryPeer::getInstanceFromPool($key3);
- if (!$obj3) {
-
- $cls = TaxRuleCountryPeer::getOMClass();
-
- $obj3 = new $cls();
- $obj3->hydrate($row, $startcol3);
- TaxRuleCountryPeer::addInstanceToPool($obj3, $key3);
- } // if $obj3 already loaded
-
- // Add the $obj1 (TaxRule) to the collection in $obj3 (TaxRuleCountry)
- $obj1->setTaxRuleCountry($obj3);
-
- } // if joined row is not null
-
- $results[] = $obj1;
- }
- $stmt->closeCursor();
-
- return $results;
- }
-
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php
index c7105c311..0a96357bf 100644
--- a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php
@@ -74,7 +74,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
- public function __construct($dbName = 'mydb', $modelName = 'Thelia\\Model\\TaxRule', $modelAlias = null)
+ public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\TaxRule', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
@@ -250,12 +250,6 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
* $query->filterById(array('min' => 12)); // WHERE id > 12
*
*
- * @see filterByProduct()
- *
- * @see filterByTaxRuleCountry()
- *
- * @see filterByTaxRuleDesc()
- *
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -391,7 +385,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
/**
* Filter the query by a related Product object
*
- * @param Product|PropelObjectCollection $product The related object(s) to use as filter
+ * @param Product|PropelObjectCollection $product the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return TaxRuleQuery The current query, for fluid interface
@@ -403,12 +397,10 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
return $this
->addUsingAlias(TaxRulePeer::ID, $product->getTaxRuleId(), $comparison);
} elseif ($product instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(TaxRulePeer::ID, $product->toKeyValue('PrimaryKey', 'TaxRuleId'), $comparison);
+ ->useProductQuery()
+ ->filterByPrimaryKeys($product->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
}
@@ -422,7 +414,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
*
* @return TaxRuleQuery The current query, for fluid interface
*/
- public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Product');
@@ -457,7 +449,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
*
* @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
*/
- public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinProduct($relationAlias, $joinType)
@@ -467,7 +459,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
/**
* Filter the query by a related TaxRuleCountry object
*
- * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry The related object(s) to use as filter
+ * @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
@@ -479,12 +471,10 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
return $this
->addUsingAlias(TaxRulePeer::ID, $taxRuleCountry->getTaxRuleId(), $comparison);
} elseif ($taxRuleCountry instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(TaxRulePeer::ID, $taxRuleCountry->toKeyValue('PrimaryKey', 'TaxRuleId'), $comparison);
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection');
}
@@ -498,7 +488,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
*
* @return TaxRuleQuery The current query, for fluid interface
*/
- public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('TaxRuleCountry');
@@ -533,7 +523,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
*/
- public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinTaxRuleCountry($relationAlias, $joinType)
@@ -543,7 +533,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
/**
* Filter the query by a related TaxRuleDesc object
*
- * @param TaxRuleDesc|PropelObjectCollection $taxRuleDesc The related object(s) to use as filter
+ * @param TaxRuleDesc|PropelObjectCollection $taxRuleDesc 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
@@ -555,12 +545,10 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
return $this
->addUsingAlias(TaxRulePeer::ID, $taxRuleDesc->getTaxRuleId(), $comparison);
} elseif ($taxRuleDesc instanceof PropelObjectCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
-
return $this
- ->addUsingAlias(TaxRulePeer::ID, $taxRuleDesc->toKeyValue('PrimaryKey', 'TaxRuleId'), $comparison);
+ ->useTaxRuleDescQuery()
+ ->filterByPrimaryKeys($taxRuleDesc->getPrimaryKeys())
+ ->endUse();
} else {
throw new PropelException('filterByTaxRuleDesc() only accepts arguments of type TaxRuleDesc or PropelCollection');
}
@@ -574,7 +562,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
*
* @return TaxRuleQuery The current query, for fluid interface
*/
- public function joinTaxRuleDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinTaxRuleDesc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('TaxRuleDesc');
@@ -609,7 +597,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxRuleDescQuery A secondary query class using the current class as primary query
*/
- public function useTaxRuleDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useTaxRuleDescQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinTaxRuleDesc($relationAlias, $joinType)
diff --git a/local/config/build.properties.sample b/local/config/build.properties.sample
new file mode 100644
index 000000000..4f9c7788e
--- /dev/null
+++ b/local/config/build.properties.sample
@@ -0,0 +1,31 @@
+# Database driver
+propel.database = mysql
+
+# Project name
+propel.project = thelia
+
+propel.schema.validate = false
+
+propel.namespace.autoPackage = true
+
+# The directory where Propel should output generated object model classes.
+propel.php.dir = ${propel.project.dir}/../../core/lib
+
+# The database PDO connection settings at builtime.
+# This setting is required for the sql, reverse, and datasql tasks.
+# Note that some drivers (e.g. mysql, oracle) require that you specify the
+# username and password separately from the DSN, which is why they are
+# available as options.
+# Example PDO connection strings:
+# mysql:host=localhost;port=3307;dbname=testdb
+# sqlite:/opt/databases/mydb.sq3
+# sqlite::memory:
+# pgsql:host=localhost;port=5432;dbname=testdb;user=bruce;password=mypass
+# oci:dbname=//localhost:1521/mydb
+# SEE http://propelorm.org/reference/buildtime-configuration
+propel.database.url = {empty}|string
+propel.database.user = {empty}|string
+propel.database.password = {empty}|string
+
+
+propel.mysql.tableType = InnoDB
\ No newline at end of file
diff --git a/local/config/schema.xml b/local/config/schema.xml
new file mode 100644
index 000000000..51bbbd716
--- /dev/null
+++ b/local/config/schema.xml
@@ -0,0 +1,1153 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/local/config/thelia.schema.xml b/local/config/thelia.schema.xml
deleted file mode 100644
index 2b7356748..000000000
--- a/local/config/thelia.schema.xml
+++ /dev/null
@@ -1,1432 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file