diff --git a/core/bootstrap.php b/core/bootstrap.php
index 20b4f2f0a..c0703656f 100644
--- a/core/bootstrap.php
+++ b/core/bootstrap.php
@@ -10,6 +10,8 @@ if (!isset($env)) {
* Functions needed for Thelia bootstrap
*/
define('THELIA_ROOT', __DIR__ .'/../');
+define('THELIA_CONF_DIR', THELIA_ROOT . '/local/config');
+define('THELIA_PLUGIN_DIR', THELIA_ROOT . '/local/plugins');
$loader = require __DIR__ . '/autoload.php';
diff --git a/core/lib/Thelia/Core/Bundle/PropelBundle.php b/core/lib/Thelia/Core/Bundle/PropelBundle.php
new file mode 100644
index 000000000..10ab64aaa
--- /dev/null
+++ b/core/lib/Thelia/Core/Bundle/PropelBundle.php
@@ -0,0 +1,44 @@
+. */
+/* */
+/*************************************************************************************/
+namespace Thelia\Core\Bundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+
+use \Propel;
+
+class PropelBundle extends Bundle
+{
+ /**
+ *
+ * Construct the depency injection builder
+ *
+ * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
+ */
+
+ public function build(ContainerBuilder $container)
+ {
+ Propel::init(THELIA_CONF_DIR . "/config_thelia.php");
+ }
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php
index 04779e0ae..fddc2e332 100644
--- a/core/lib/Thelia/Core/Thelia.php
+++ b/core/lib/Thelia/Core/Thelia.php
@@ -116,6 +116,7 @@ class Thelia extends Kernel
$bundles = array(
/* TheliaBundle contain all the dependency injection description */
new Bundle\TheliaBundle(),
+ new Bundle\PropelBundle()
);
/**
diff --git a/core/lib/Thelia/Model/Accessory.php b/core/lib/Thelia/Model/Accessory.php
new file mode 100644
index 000000000..8c5b138ed
--- /dev/null
+++ b/core/lib/Thelia/Model/Accessory.php
@@ -0,0 +1,21 @@
+findOneByName($search);
+
+ return $value ? $value->getValue() : $default;
+ }
+}
diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php
new file mode 100644
index 000000000..0c509e0e1
--- /dev/null
+++ b/core/lib/Thelia/Model/Content.php
@@ -0,0 +1,21 @@
+setName('accessory');
+ $this->setPhpName('Accessory');
+ $this->setClassname('Thelia\\Model\\Accessory');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addForeignKey('ACCESSORY', 'Accessory', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('ProductRelatedByProductId', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('ProductRelatedByAccessory', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('accessory' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // AccessoryTableMap
diff --git a/core/lib/Thelia/Model/map/AddressTableMap.php b/core/lib/Thelia/Model/map/AddressTableMap.php
new file mode 100644
index 000000000..ea9041a94
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AddressTableMap.php
@@ -0,0 +1,73 @@
+setName('address');
+ $this->setPhpName('Address');
+ $this->setClassname('Thelia\\Model\\Address');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
+ $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
+ $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', true, 255, null);
+ $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null);
+ $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
+ $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
+ $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), null, null);
+ } // buildRelations()
+
+} // AddressTableMap
diff --git a/core/lib/Thelia/Model/map/AdminGroupTableMap.php b/core/lib/Thelia/Model/map/AdminGroupTableMap.php
new file mode 100644
index 000000000..9acd8ad4f
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AdminGroupTableMap.php
@@ -0,0 +1,62 @@
+setName('admin_group');
+ $this->setPhpName('AdminGroup');
+ $this->setClassname('Thelia\\Model\\AdminGroup');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', false, null, null);
+ $this->addForeignKey('ADMIN_ID', 'AdminId', 'INTEGER', 'admin', 'ID', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Admin', 'Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // AdminGroupTableMap
diff --git a/core/lib/Thelia/Model/map/AdminLogTableMap.php b/core/lib/Thelia/Model/map/AdminLogTableMap.php
new file mode 100644
index 000000000..9728a97ee
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AdminLogTableMap.php
@@ -0,0 +1,63 @@
+setName('admin_log');
+ $this->setPhpName('AdminLog');
+ $this->setClassname('Thelia\\Model\\AdminLog');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('ADMIN_LOGIN', 'AdminLogin', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADMIN_FIRSTNAME', 'AdminFirstname', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADMIN_LASTNAME', 'AdminLastname', 'VARCHAR', false, 255, null);
+ $this->addColumn('ACTION', 'Action', 'VARCHAR', false, 255, null);
+ $this->addColumn('REQUEST', 'Request', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ } // buildRelations()
+
+} // AdminLogTableMap
diff --git a/core/lib/Thelia/Model/map/AdminTableMap.php b/core/lib/Thelia/Model/map/AdminTableMap.php
new file mode 100644
index 000000000..4240335a3
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AdminTableMap.php
@@ -0,0 +1,65 @@
+setName('admin');
+ $this->setPhpName('Admin');
+ $this->setClassname('Thelia\\Model\\Admin');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 100, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 100, null);
+ $this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 100, null);
+ $this->addColumn('PASSWORD', 'Password', 'VARCHAR', true, 128, null);
+ $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null);
+ $this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..28c4e3cc8
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AreaTableMap.php
@@ -0,0 +1,62 @@
+setName('area');
+ $this->setPhpName('Area');
+ $this->setClassname('Thelia\\Model\\Area');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('NAME', 'Name', 'VARCHAR', true, 100, null);
+ $this->addColumn('UNIT', 'Unit', 'FLOAT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', null, 'Countrys');
+ $this->addRelation('Delivzone', 'Thelia\\Model\\Delivzone', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', null, 'Delivzones');
+ } // buildRelations()
+
+} // AreaTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php b/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php
new file mode 100644
index 000000000..8aca46635
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php
@@ -0,0 +1,64 @@
+setName('attribute_av_desc');
+ $this->setPhpName('AttributeAvDesc');
+ $this->setClassname('Thelia\\Model\\AttributeAvDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..4f1a03b92
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AttributeAvTableMap.php
@@ -0,0 +1,63 @@
+setName('attribute_av');
+ $this->setPhpName('AttributeAv');
+ $this->setClassname('Thelia\\Model\\AttributeAv');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('AttributeAvDesc', 'Thelia\\Model\\AttributeAvDesc', RelationMap::ONE_TO_MANY, array('id' => 'attribute_av_id', ), 'CASCADE', null, 'AttributeAvDescs');
+ $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_av_id', ), 'CASCADE', null, 'AttributeCombinations');
+ } // buildRelations()
+
+} // AttributeAvTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php
new file mode 100644
index 000000000..eca24088c
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php
@@ -0,0 +1,62 @@
+setName('attribute_category');
+ $this->setPhpName('AttributeCategory');
+ $this->setClassname('Thelia\\Model\\AttributeCategory');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null);
+ $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // AttributeCategoryTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php
new file mode 100644
index 000000000..aa52a5702
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php
@@ -0,0 +1,64 @@
+setName('attribute_combination');
+ $this->setPhpName('AttributeCombination');
+ $this->setClassname('Thelia\\Model\\AttributeCombination');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignPrimaryKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER' , 'attribute', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('COMBINATION_ID', 'CombinationId', 'INTEGER' , 'combination', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER' , 'attribute_av', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // AttributeCombinationTableMap
diff --git a/core/lib/Thelia/Model/map/AttributeDescTableMap.php b/core/lib/Thelia/Model/map/AttributeDescTableMap.php
new file mode 100644
index 000000000..084523b3a
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AttributeDescTableMap.php
@@ -0,0 +1,64 @@
+setName('attribute_desc');
+ $this->setPhpName('AttributeDesc');
+ $this->setClassname('Thelia\\Model\\AttributeDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, 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);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..d9dd0f1e5
--- /dev/null
+++ b/core/lib/Thelia/Model/map/AttributeTableMap.php
@@ -0,0 +1,63 @@
+setName('attribute');
+ $this->setPhpName('Attribute');
+ $this->setClassname('Thelia\\Model\\Attribute');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', null, 'AttributeAvs');
+ $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', null, 'AttributeCategorys');
+ $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', null, 'AttributeCombinations');
+ $this->addRelation('AttributeDesc', 'Thelia\\Model\\AttributeDesc', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', null, 'AttributeDescs');
+ } // buildRelations()
+
+} // AttributeTableMap
diff --git a/core/lib/Thelia/Model/map/CategoryDescTableMap.php b/core/lib/Thelia/Model/map/CategoryDescTableMap.php
new file mode 100644
index 000000000..0c32a58d9
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CategoryDescTableMap.php
@@ -0,0 +1,65 @@
+setName('category_desc');
+ $this->setPhpName('CategoryDesc');
+ $this->setClassname('Thelia\\Model\\CategoryDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..2231277ac
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CategoryTableMap.php
@@ -0,0 +1,70 @@
+setName('category');
+ $this->setPhpName('Category');
+ $this->setClassname('Thelia\\Model\\Category');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
+ $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'AttributeCategorys');
+ $this->addRelation('CategoryDesc', 'Thelia\\Model\\CategoryDesc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'CategoryDescs');
+ $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'ContentAssocs');
+ $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'Documents');
+ $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'FeatureCategorys');
+ $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'Images');
+ $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'ProductCategorys');
+ $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'Rewritings');
+ } // buildRelations()
+
+} // CategoryTableMap
diff --git a/core/lib/Thelia/Model/map/CombinationTableMap.php b/core/lib/Thelia/Model/map/CombinationTableMap.php
new file mode 100644
index 000000000..5b741dcc4
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CombinationTableMap.php
@@ -0,0 +1,61 @@
+setName('combination');
+ $this->setPhpName('Combination');
+ $this->setClassname('Thelia\\Model\\Combination');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'CASCADE', null, 'AttributeCombinations');
+ $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'SET NULL', null, 'Stocks');
+ } // buildRelations()
+
+} // CombinationTableMap
diff --git a/core/lib/Thelia/Model/map/ConfigDescTableMap.php b/core/lib/Thelia/Model/map/ConfigDescTableMap.php
new file mode 100644
index 000000000..d0176ff14
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ConfigDescTableMap.php
@@ -0,0 +1,64 @@
+setName('config_desc');
+ $this->setPhpName('ConfigDesc');
+ $this->setClassname('Thelia\\Model\\ConfigDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..705a0ca0c
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ConfigTableMap.php
@@ -0,0 +1,63 @@
+setName('config');
+ $this->setPhpName('Config');
+ $this->setClassname('Thelia\\Model\\Config');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('NAME', 'Name', 'VARCHAR', true, 255, null);
+ $this->addColumn('VALUE', 'Value', 'VARCHAR', true, 255, null);
+ $this->addColumn('SECURE', 'Secure', 'TINYINT', true, null, 1);
+ $this->addColumn('HIDDEN', 'Hidden', 'TINYINT', true, null, 1);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..0650f7d4c
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ContentAssocTableMap.php
@@ -0,0 +1,65 @@
+setName('content_assoc');
+ $this->setPhpName('ContentAssoc');
+ $this->setClassname('Thelia\\Model\\ContentAssoc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // ContentAssocTableMap
diff --git a/core/lib/Thelia/Model/map/ContentDescTableMap.php b/core/lib/Thelia/Model/map/ContentDescTableMap.php
new file mode 100644
index 000000000..489d7a478
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ContentDescTableMap.php
@@ -0,0 +1,65 @@
+setName('content_desc');
+ $this->setPhpName('ContentDesc');
+ $this->setClassname('Thelia\\Model\\ContentDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..f0fe4a58a
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ContentFolderTableMap.php
@@ -0,0 +1,59 @@
+setName('content_folder');
+ $this->setPhpName('ContentFolder');
+ $this->setClassname('Thelia\\Model\\ContentFolder');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('CONTENT_ID', 'ContentId', 'INTEGER' , 'content', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('FOLDER_ID', 'FolderId', 'INTEGER' , 'folder', 'ID', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // ContentFolderTableMap
diff --git a/core/lib/Thelia/Model/map/ContentTableMap.php b/core/lib/Thelia/Model/map/ContentTableMap.php
new file mode 100644
index 000000000..66712b485
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ContentTableMap.php
@@ -0,0 +1,66 @@
+setName('content');
+ $this->setPhpName('Content');
+ $this->setClassname('Thelia\\Model\\Content');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'ContentAssocs');
+ $this->addRelation('ContentDesc', 'Thelia\\Model\\ContentDesc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'ContentDescs');
+ $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'ContentFolders');
+ $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'Documents');
+ $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'Images');
+ $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'Rewritings');
+ } // buildRelations()
+
+} // ContentTableMap
diff --git a/core/lib/Thelia/Model/map/CountryDescTableMap.php b/core/lib/Thelia/Model/map/CountryDescTableMap.php
new file mode 100644
index 000000000..fdc6dce94
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CountryDescTableMap.php
@@ -0,0 +1,64 @@
+setName('country_desc');
+ $this->setPhpName('CountryDesc');
+ $this->setClassname('Thelia\\Model\\CountryDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..c8c11993c
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CountryTableMap.php
@@ -0,0 +1,65 @@
+setName('country');
+ $this->setPhpName('Country');
+ $this->setClassname('Thelia\\Model\\Country');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null);
+ $this->addColumn('ISOCODE', 'Isocode', 'VARCHAR', true, 4, null);
+ $this->addColumn('ISOALPHA2', 'Isoalpha2', 'VARCHAR', false, 2, null);
+ $this->addColumn('ISOALPHA3', 'Isoalpha3', 'VARCHAR', false, 4, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('CountryDesc', 'Thelia\\Model\\CountryDesc', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', null, 'CountryDescs');
+ $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', null, 'TaxRuleCountrys');
+ } // buildRelations()
+
+} // CountryTableMap
diff --git a/core/lib/Thelia/Model/map/CouponOrderTableMap.php b/core/lib/Thelia/Model/map/CouponOrderTableMap.php
new file mode 100644
index 000000000..a769d0a95
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CouponOrderTableMap.php
@@ -0,0 +1,62 @@
+setName('coupon_order');
+ $this->setPhpName('CouponOrder');
+ $this->setClassname('Thelia\\Model\\CouponOrder');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
+ $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..00eb5b987
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CouponRuleTableMap.php
@@ -0,0 +1,63 @@
+setName('coupon_rule');
+ $this->setPhpName('CouponRule');
+ $this->setClassname('Thelia\\Model\\CouponRule');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('COUPON_ID', 'CouponId', 'INTEGER', 'coupon', 'ID', true, null, null);
+ $this->addColumn('CONTROLLER', 'Controller', 'VARCHAR', false, 255, null);
+ $this->addColumn('OPERATION', 'Operation', 'VARCHAR', false, 255, null);
+ $this->addColumn('VALUE', 'Value', 'FLOAT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..c9a26eecf
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CouponTableMap.php
@@ -0,0 +1,66 @@
+setName('coupon');
+ $this->setPhpName('Coupon');
+ $this->setClassname('Thelia\\Model\\Coupon');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
+ $this->addColumn('ACTION', 'Action', 'VARCHAR', true, 255, null);
+ $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
+ $this->addColumn('USED', 'Used', 'TINYINT', false, null, null);
+ $this->addColumn('AVAILABLE_SINCE', 'AvailableSince', 'TIMESTAMP', false, null, null);
+ $this->addColumn('DATE_LIMIT', 'DateLimit', 'TIMESTAMP', false, null, null);
+ $this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..4a6b80439
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CurrencyTableMap.php
@@ -0,0 +1,64 @@
+setName('currency');
+ $this->setPhpName('Currency');
+ $this->setClassname('Thelia\\Model\\Currency');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('NAME', 'Name', 'VARCHAR', false, 45, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
+ $this->addColumn('SYMBOL', 'Symbol', 'VARCHAR', false, 45, null);
+ $this->addColumn('RATE', 'Rate', 'FLOAT', false, null, null);
+ $this->addColumn('DEFAULT_UTILITY', 'DefaultUtility', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..68f2d52af
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CustomerTableMap.php
@@ -0,0 +1,82 @@
+setName('customer');
+ $this->setPhpName('Customer');
+ $this->setClassname('Thelia\\Model\\Customer');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, null);
+ $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
+ $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null);
+ $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', false, 10, null);
+ $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
+ $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
+ $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
+ $this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null);
+ $this->addColumn('EMAIL', 'Email', 'VARCHAR', false, 50, null);
+ $this->addColumn('PASSWORD', 'Password', 'VARCHAR', false, 255, null);
+ $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null);
+ $this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null);
+ $this->addColumn('RESELLER', 'Reseller', 'TINYINT', false, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null);
+ $this->addColumn('SPONSOR', 'Sponsor', 'VARCHAR', false, 50, null);
+ $this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', null, 'Addresss');
+ $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', null, 'Orders');
+ } // buildRelations()
+
+} // CustomerTableMap
diff --git a/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php
new file mode 100644
index 000000000..3e2f4408d
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php
@@ -0,0 +1,63 @@
+setName('customer_title_desc');
+ $this->setPhpName('CustomerTitleDesc');
+ $this->setClassname('Thelia\\Model\\CustomerTitleDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..6de110a47
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CustomerTitleTableMap.php
@@ -0,0 +1,63 @@
+setName('customer_title');
+ $this->setPhpName('CustomerTitle');
+ $this->setClassname('Thelia\\Model\\CustomerTitle');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $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);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), null, null, 'Addresss');
+ $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'SET NULL', null, 'Customers');
+ $this->addRelation('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
new file mode 100644
index 000000000..86c4fe5e4
--- /dev/null
+++ b/core/lib/Thelia/Model/map/DelivzoneTableMap.php
@@ -0,0 +1,61 @@
+setName('delivzone');
+ $this->setPhpName('Delivzone');
+ $this->setClassname('Thelia\\Model\\Delivzone');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null);
+ $this->addColumn('DELIVERY', 'Delivery', 'VARCHAR', true, 45, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..f181e3421
--- /dev/null
+++ b/core/lib/Thelia/Model/map/DocumentDescTableMap.php
@@ -0,0 +1,64 @@
+setName('document_desc');
+ $this->setPhpName('DocumentDesc');
+ $this->setClassname('Thelia\\Model\\DocumentDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..b305f8a00
--- /dev/null
+++ b/core/lib/Thelia/Model/map/DocumentTableMap.php
@@ -0,0 +1,69 @@
+setName('document');
+ $this->setPhpName('Document');
+ $this->setClassname('Thelia\\Model\\Document');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
+ $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('DocumentDesc', 'Thelia\\Model\\DocumentDesc', RelationMap::ONE_TO_MANY, array('id' => 'document_id', ), 'CASCADE', null, 'DocumentDescs');
+ } // buildRelations()
+
+} // DocumentTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php b/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php
new file mode 100644
index 000000000..001844e65
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php
@@ -0,0 +1,62 @@
+setName('feature_av_desc');
+ $this->setPhpName('FeatureAvDesc');
+ $this->setClassname('Thelia\\Model\\FeatureAvDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..fa56c5b6e
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FeatureAvTableMap.php
@@ -0,0 +1,62 @@
+setName('feature_av');
+ $this->setPhpName('FeatureAv');
+ $this->setClassname('Thelia\\Model\\FeatureAv');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('FeatureAvDesc', 'Thelia\\Model\\FeatureAvDesc', RelationMap::ONE_TO_MANY, array('id' => 'feature_av_id', ), 'CASCADE', null, 'FeatureAvDescs');
+ $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_av_id', ), 'CASCADE', null, 'FeatureProds');
+ } // buildRelations()
+
+} // FeatureAvTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php
new file mode 100644
index 000000000..2aaedcba4
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php
@@ -0,0 +1,62 @@
+setName('feature_category');
+ $this->setPhpName('FeatureCategory');
+ $this->setClassname('Thelia\\Model\\FeatureCategory');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // FeatureCategoryTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureDescTableMap.php b/core/lib/Thelia/Model/map/FeatureDescTableMap.php
new file mode 100644
index 000000000..dbff3c642
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FeatureDescTableMap.php
@@ -0,0 +1,64 @@
+setName('feature_desc');
+ $this->setPhpName('FeatureDesc');
+ $this->setClassname('Thelia\\Model\\FeatureDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'VARCHAR', false, 45, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..24cde96d3
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FeatureProdTableMap.php
@@ -0,0 +1,66 @@
+setName('feature_prod');
+ $this->setPhpName('FeatureProd');
+ $this->setClassname('Thelia\\Model\\FeatureProd');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
+ $this->addForeignKey('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', 'feature_av', 'ID', false, null, null);
+ $this->addColumn('DEFAULT_UTILITY', 'DefaultUtility', 'VARCHAR', false, 255, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // FeatureProdTableMap
diff --git a/core/lib/Thelia/Model/map/FeatureTableMap.php b/core/lib/Thelia/Model/map/FeatureTableMap.php
new file mode 100644
index 000000000..4378e8489
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FeatureTableMap.php
@@ -0,0 +1,64 @@
+setName('feature');
+ $this->setPhpName('Feature');
+ $this->setClassname('Thelia\\Model\\Feature');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('VISIBLE', 'Visible', 'INTEGER', false, null, 0);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', null, 'FeatureAvs');
+ $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', null, 'FeatureCategorys');
+ $this->addRelation('FeatureDesc', 'Thelia\\Model\\FeatureDesc', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', null, 'FeatureDescs');
+ $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', null, 'FeatureProds');
+ } // buildRelations()
+
+} // FeatureTableMap
diff --git a/core/lib/Thelia/Model/map/FolderDescTableMap.php b/core/lib/Thelia/Model/map/FolderDescTableMap.php
new file mode 100644
index 000000000..40f5aa1e3
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FolderDescTableMap.php
@@ -0,0 +1,65 @@
+setName('folder_desc');
+ $this->setPhpName('FolderDesc');
+ $this->setClassname('Thelia\\Model\\FolderDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..bf0513351
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FolderTableMap.php
@@ -0,0 +1,67 @@
+setName('folder');
+ $this->setPhpName('Folder');
+ $this->setClassname('Thelia\\Model\\Folder');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null);
+ $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'ContentFolders');
+ $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'Documents');
+ $this->addRelation('FolderDesc', 'Thelia\\Model\\FolderDesc', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'FolderDescs');
+ $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'Images');
+ $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'Rewritings');
+ } // buildRelations()
+
+} // FolderTableMap
diff --git a/core/lib/Thelia/Model/map/GroupDescTableMap.php b/core/lib/Thelia/Model/map/GroupDescTableMap.php
new file mode 100644
index 000000000..543b7e66a
--- /dev/null
+++ b/core/lib/Thelia/Model/map/GroupDescTableMap.php
@@ -0,0 +1,64 @@
+setName('group_desc');
+ $this->setPhpName('GroupDesc');
+ $this->setClassname('Thelia\\Model\\GroupDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..0224f234c
--- /dev/null
+++ b/core/lib/Thelia/Model/map/GroupModuleTableMap.php
@@ -0,0 +1,63 @@
+setName('group_module');
+ $this->setPhpName('GroupModule');
+ $this->setClassname('Thelia\\Model\\GroupModule');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null);
+ $this->addForeignKey('MODULE_ID', 'ModuleId', 'INTEGER', 'module', 'ID', false, null, null);
+ $this->addColumn('ACCESS', 'Access', 'TINYINT', false, null, 0);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'CASCADE');
+ $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // GroupModuleTableMap
diff --git a/core/lib/Thelia/Model/map/GroupResourceTableMap.php b/core/lib/Thelia/Model/map/GroupResourceTableMap.php
new file mode 100644
index 000000000..ba5d42e8c
--- /dev/null
+++ b/core/lib/Thelia/Model/map/GroupResourceTableMap.php
@@ -0,0 +1,64 @@
+setName('group_resource');
+ $this->setPhpName('GroupResource');
+ $this->setClassname('Thelia\\Model\\GroupResource');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null);
+ $this->addForeignKey('RESOURCE_ID', 'ResourceId', 'INTEGER', 'resource', 'ID', true, null, null);
+ $this->addColumn('READ', 'Read', 'TINYINT', false, null, 0);
+ $this->addColumn('WRITE', 'Write', 'TINYINT', false, null, 0);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // GroupResourceTableMap
diff --git a/core/lib/Thelia/Model/map/GroupTableMap.php b/core/lib/Thelia/Model/map/GroupTableMap.php
new file mode 100644
index 000000000..7b38a8781
--- /dev/null
+++ b/core/lib/Thelia/Model/map/GroupTableMap.php
@@ -0,0 +1,63 @@
+setName('group');
+ $this->setPhpName('Group');
+ $this->setClassname('Thelia\\Model\\Group');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', null, 'AdminGroups');
+ $this->addRelation('GroupDesc', 'Thelia\\Model\\GroupDesc', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', null, 'GroupDescs');
+ $this->addRelation('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
new file mode 100644
index 000000000..9aa41ad64
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ImageDescTableMap.php
@@ -0,0 +1,63 @@
+setName('image_desc');
+ $this->setPhpName('ImageDesc');
+ $this->setClassname('Thelia\\Model\\ImageDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, 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);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..d53b7e180
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ImageTableMap.php
@@ -0,0 +1,69 @@
+setName('image');
+ $this->setPhpName('Image');
+ $this->setClassname('Thelia\\Model\\Image');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
+ $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('ImageDesc', 'Thelia\\Model\\ImageDesc', RelationMap::ONE_TO_MANY, array('id' => 'image_id', ), 'CASCADE', null, 'ImageDescs');
+ } // buildRelations()
+
+} // ImageTableMap
diff --git a/core/lib/Thelia/Model/map/LangTableMap.php b/core/lib/Thelia/Model/map/LangTableMap.php
new file mode 100644
index 000000000..f7c93fef6
--- /dev/null
+++ b/core/lib/Thelia/Model/map/LangTableMap.php
@@ -0,0 +1,62 @@
+setName('lang');
+ $this->setPhpName('Lang');
+ $this->setClassname('Thelia\\Model\\Lang');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 100, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 10, null);
+ $this->addColumn('URL', 'Url', 'VARCHAR', false, 255, null);
+ $this->addColumn('DEFAULT_UTILITY', 'DefaultUtility', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ } // buildRelations()
+
+} // LangTableMap
diff --git a/core/lib/Thelia/Model/map/MessageDescTableMap.php b/core/lib/Thelia/Model/map/MessageDescTableMap.php
new file mode 100644
index 000000000..f4b6705d4
--- /dev/null
+++ b/core/lib/Thelia/Model/map/MessageDescTableMap.php
@@ -0,0 +1,64 @@
+setName('message_desc');
+ $this->setPhpName('MessageDesc');
+ $this->setClassname('Thelia\\Model\\MessageDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'VARCHAR', true, 45, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..06e7c34eb
--- /dev/null
+++ b/core/lib/Thelia/Model/map/MessageTableMap.php
@@ -0,0 +1,61 @@
+setName('message');
+ $this->setPhpName('Message');
+ $this->setClassname('Thelia\\Model\\Message');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
+ $this->addColumn('SECURE', 'Secure', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..529bc408d
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ModuleDescTableMap.php
@@ -0,0 +1,65 @@
+setName('module_desc');
+ $this->setPhpName('ModuleDesc');
+ $this->setClassname('Thelia\\Model\\ModuleDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CURRENCY_ID', 'CurrencyId', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..21eb422b7
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ModuleTableMap.php
@@ -0,0 +1,64 @@
+setName('module');
+ $this->setPhpName('Module');
+ $this->setClassname('Thelia\\Model\\Module');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 55, null);
+ $this->addColumn('TYPE', 'Type', 'TINYINT', true, null, null);
+ $this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('GroupModule', 'Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', null, 'GroupModules');
+ $this->addRelation('ModuleDesc', 'Thelia\\Model\\ModuleDesc', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', null, 'ModuleDescs');
+ } // buildRelations()
+
+} // ModuleTableMap
diff --git a/core/lib/Thelia/Model/map/OrderAddressTableMap.php b/core/lib/Thelia/Model/map/OrderAddressTableMap.php
new file mode 100644
index 000000000..91a63e855
--- /dev/null
+++ b/core/lib/Thelia/Model/map/OrderAddressTableMap.php
@@ -0,0 +1,71 @@
+setName('order_address');
+ $this->setPhpName('OrderAddress');
+ $this->setClassname('Thelia\\Model\\OrderAddress');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', false, null, null);
+ $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null);
+ $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null);
+ $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
+ $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
+ $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('OrderRelatedByAddressInvoice', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice', ), 'SET NULL', null, 'OrdersRelatedByAddressInvoice');
+ $this->addRelation('OrderRelatedByAddressDelivery', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery', ), 'SET NULL', null, 'OrdersRelatedByAddressDelivery');
+ } // buildRelations()
+
+} // OrderAddressTableMap
diff --git a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php
new file mode 100644
index 000000000..5c62094ae
--- /dev/null
+++ b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php
@@ -0,0 +1,62 @@
+setName('order_feature');
+ $this->setPhpName('OrderFeature');
+ $this->setClassname('Thelia\\Model\\OrderFeature');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null);
+ $this->addColumn('FEATURE_DESC', 'FeatureDesc', 'VARCHAR', false, 255, null);
+ $this->addColumn('FEATURE_AV_DESC', 'FeatureAvDesc', 'VARCHAR', false, 255, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..864073c5b
--- /dev/null
+++ b/core/lib/Thelia/Model/map/OrderProductTableMap.php
@@ -0,0 +1,69 @@
+setName('order_product');
+ $this->setPhpName('OrderProduct');
+ $this->setClassname('Thelia\\Model\\OrderProduct');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
+ $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
+ $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
+ $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('OrderFeature', 'Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', null, 'OrderFeatures');
+ } // buildRelations()
+
+} // OrderProductTableMap
diff --git a/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php b/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php
new file mode 100644
index 000000000..0e1d342d1
--- /dev/null
+++ b/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php
@@ -0,0 +1,64 @@
+setName('order_status_desc');
+ $this->setPhpName('OrderStatusDesc');
+ $this->setClassname('Thelia\\Model\\OrderStatusDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..eaf2a978e
--- /dev/null
+++ b/core/lib/Thelia/Model/map/OrderStatusTableMap.php
@@ -0,0 +1,61 @@
+setName('order_status');
+ $this->setPhpName('OrderStatus');
+ $this->setClassname('Thelia\\Model\\OrderStatus');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'SET NULL', null, 'Orders');
+ $this->addRelation('OrderStatusDesc', 'Thelia\\Model\\OrderStatusDesc', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'CASCADE', null, 'OrderStatusDescs');
+ } // buildRelations()
+
+} // OrderStatusTableMap
diff --git a/core/lib/Thelia/Model/map/OrderTableMap.php b/core/lib/Thelia/Model/map/OrderTableMap.php
new file mode 100644
index 000000000..12e73713d
--- /dev/null
+++ b/core/lib/Thelia/Model/map/OrderTableMap.php
@@ -0,0 +1,80 @@
+setName('order');
+ $this->setPhpName('Order');
+ $this->setClassname('Thelia\\Model\\Order');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null);
+ $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
+ $this->addForeignKey('ADDRESS_INVOICE', 'AddressInvoice', 'INTEGER', 'order_address', 'ID', false, null, null);
+ $this->addForeignKey('ADDRESS_DELIVERY', 'AddressDelivery', 'INTEGER', 'order_address', 'ID', false, null, null);
+ $this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', false, null, null);
+ $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', false, null, null);
+ $this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', true, null, null);
+ $this->addColumn('TRANSACTION', 'Transaction', 'VARCHAR', false, 100, null);
+ $this->addColumn('DELIVERY_NUM', 'DeliveryNum', 'VARCHAR', false, 100, null);
+ $this->addColumn('INVOICE', 'Invoice', 'VARCHAR', false, 100, null);
+ $this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null);
+ $this->addColumn('PAYMENT', 'Payment', 'VARCHAR', true, 45, null);
+ $this->addColumn('CARRIER', 'Carrier', 'VARCHAR', true, 45, null);
+ $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'order_status', 'ID', false, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Currency', 'Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('OrderAddressRelatedByAddressInvoice', 'Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_invoice' => 'id', ), 'SET NULL', null);
+ $this->addRelation('OrderAddressRelatedByAddressDelivery', 'Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_delivery' => 'id', ), 'SET NULL', null);
+ $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('CouponOrder', 'Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', null, 'CouponOrders');
+ $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', null, 'OrderProducts');
+ } // buildRelations()
+
+} // OrderTableMap
diff --git a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php
new file mode 100644
index 000000000..759ac44ab
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php
@@ -0,0 +1,59 @@
+setName('product_category');
+ $this->setPhpName('ProductCategory');
+ $this->setClassname('Thelia\\Model\\ProductCategory');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'INTEGER' , 'product', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('CATEGORY_ID', 'CategoryId', 'INTEGER' , 'category', 'ID', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // ProductCategoryTableMap
diff --git a/core/lib/Thelia/Model/map/ProductDescTableMap.php b/core/lib/Thelia/Model/map/ProductDescTableMap.php
new file mode 100644
index 000000000..1e1300145
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ProductDescTableMap.php
@@ -0,0 +1,65 @@
+setName('product_desc');
+ $this->setPhpName('ProductDesc');
+ $this->setClassname('Thelia\\Model\\ProductDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATET_AT', 'UpdatetAt', 'VARCHAR', true, 45, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..15ed9a9d3
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ProductTableMap.php
@@ -0,0 +1,80 @@
+setName('product');
+ $this->setPhpName('Product');
+ $this->setClassname('Thelia\\Model\\Product');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null);
+ $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
+ $this->addColumn('PRICE2', 'Price2', 'FLOAT', false, null, null);
+ $this->addColumn('ECOTAX', 'Ecotax', 'FLOAT', false, null, null);
+ $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0);
+ $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0);
+ $this->addColumn('QUANTITY', 'Quantity', 'INTEGER', false, null, 0);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0);
+ $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('AccessoryRelatedByProductId', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'AccessorysRelatedByProductId');
+ $this->addRelation('AccessoryRelatedByAccessory', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', null, 'AccessorysRelatedByAccessory');
+ $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'ContentAssocs');
+ $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'Documents');
+ $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'FeatureProds');
+ $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'Images');
+ $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'ProductCategorys');
+ $this->addRelation('ProductDesc', 'Thelia\\Model\\ProductDesc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'ProductDescs');
+ $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'Rewritings');
+ $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'Stocks');
+ } // buildRelations()
+
+} // ProductTableMap
diff --git a/core/lib/Thelia/Model/map/ResourceDescTableMap.php b/core/lib/Thelia/Model/map/ResourceDescTableMap.php
new file mode 100644
index 000000000..1a0ec7b29
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ResourceDescTableMap.php
@@ -0,0 +1,62 @@
+setName('resource_desc');
+ $this->setPhpName('ResourceDesc');
+ $this->setClassname('Thelia\\Model\\ResourceDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..d2a07cfd2
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ResourceTableMap.php
@@ -0,0 +1,61 @@
+setName('resource');
+ $this->setPhpName('Resource');
+ $this->setClassname('Thelia\\Model\\Resource');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', null, 'GroupResources');
+ $this->addRelation('ResourceDesc', 'Thelia\\Model\\ResourceDesc', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', null, 'ResourceDescs');
+ } // buildRelations()
+
+} // ResourceTableMap
diff --git a/core/lib/Thelia/Model/map/RewritingTableMap.php b/core/lib/Thelia/Model/map/RewritingTableMap.php
new file mode 100644
index 000000000..e895a0181
--- /dev/null
+++ b/core/lib/Thelia/Model/map/RewritingTableMap.php
@@ -0,0 +1,67 @@
+setName('rewriting');
+ $this->setPhpName('Rewriting');
+ $this->setClassname('Thelia\\Model\\Rewriting');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // RewritingTableMap
diff --git a/core/lib/Thelia/Model/map/StockTableMap.php b/core/lib/Thelia/Model/map/StockTableMap.php
new file mode 100644
index 000000000..b4aa0cab1
--- /dev/null
+++ b/core/lib/Thelia/Model/map/StockTableMap.php
@@ -0,0 +1,64 @@
+setName('stock');
+ $this->setPhpName('Stock');
+ $this->setClassname('Thelia\\Model\\Stock');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('COMBINATION_ID', 'CombinationId', 'INTEGER', 'combination', 'ID', false, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addColumn('INCREASE', 'Increase', 'FLOAT', false, null, null);
+ $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // StockTableMap
diff --git a/core/lib/Thelia/Model/map/TaxDescTableMap.php b/core/lib/Thelia/Model/map/TaxDescTableMap.php
new file mode 100644
index 000000000..767a73cac
--- /dev/null
+++ b/core/lib/Thelia/Model/map/TaxDescTableMap.php
@@ -0,0 +1,63 @@
+setName('tax_desc');
+ $this->setPhpName('TaxDesc');
+ $this->setClassname('Thelia\\Model\\TaxDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', '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);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..e079f9f71
--- /dev/null
+++ b/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php
@@ -0,0 +1,65 @@
+setName('tax_rule_country');
+ $this->setPhpName('TaxRuleCountry');
+ $this->setClassname('Thelia\\Model\\TaxRuleCountry');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
+ $this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', false, null, null);
+ $this->addForeignKey('TAX_ID', 'TaxId', 'INTEGER', 'tax', 'ID', false, null, null);
+ $this->addColumn('NONE', 'None', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // TaxRuleCountryTableMap
diff --git a/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php b/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php
new file mode 100644
index 000000000..c47c81112
--- /dev/null
+++ b/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php
@@ -0,0 +1,63 @@
+setName('tax_rule_desc');
+ $this->setPhpName('TaxRuleDesc');
+ $this->setClassname('Thelia\\Model\\TaxRuleDesc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $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
new file mode 100644
index 000000000..def7cbb5d
--- /dev/null
+++ b/core/lib/Thelia/Model/map/TaxRuleTableMap.php
@@ -0,0 +1,62 @@
+setName('tax_rule');
+ $this->setPhpName('TaxRule');
+ $this->setClassname('Thelia\\Model\\TaxRule');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'SET NULL', null, 'Products');
+ $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'CASCADE', null, 'TaxRuleCountrys');
+ $this->addRelation('TaxRuleDesc', 'Thelia\\Model\\TaxRuleDesc', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'CASCADE', null, 'TaxRuleDescs');
+ } // buildRelations()
+
+} // TaxRuleTableMap
diff --git a/core/lib/Thelia/Model/map/TaxTableMap.php b/core/lib/Thelia/Model/map/TaxTableMap.php
new file mode 100644
index 000000000..15c0c6a29
--- /dev/null
+++ b/core/lib/Thelia/Model/map/TaxTableMap.php
@@ -0,0 +1,61 @@
+setName('tax');
+ $this->setPhpName('Tax');
+ $this->setClassname('Thelia\\Model\\Tax');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('RATE', 'Rate', 'FLOAT', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('TaxDesc', 'Thelia\\Model\\TaxDesc', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'CASCADE', null, 'TaxDescs');
+ $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'SET NULL', null, 'TaxRuleCountrys');
+ } // buildRelations()
+
+} // TaxTableMap
diff --git a/core/lib/Thelia/Model/om/BaseAccessory.php b/core/lib/Thelia/Model/om/BaseAccessory.php
new file mode 100644
index 000000000..091f34f0a
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAccessory.php
@@ -0,0 +1,1280 @@
+id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [accessory] column value.
+ *
+ * @return int
+ */
+ public function getAccessory()
+ {
+ return $this->accessory;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Accessory The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AccessoryPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return Accessory The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = AccessoryPeer::PRODUCT_ID;
+ }
+
+ if ($this->aProductRelatedByProductId !== null && $this->aProductRelatedByProductId->getId() !== $v) {
+ $this->aProductRelatedByProductId = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [accessory] column.
+ *
+ * @param int $v new value
+ * @return Accessory The current object (for fluent API support)
+ */
+ public function setAccessory($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->accessory !== $v) {
+ $this->accessory = $v;
+ $this->modifiedColumns[] = AccessoryPeer::ACCESSORY;
+ }
+
+ if ($this->aProductRelatedByAccessory !== null && $this->aProductRelatedByAccessory->getId() !== $v) {
+ $this->aProductRelatedByAccessory = null;
+ }
+
+
+ return $this;
+ } // setAccessory()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Accessory The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = AccessoryPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Accessory The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AccessoryPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Accessory The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AccessoryPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->accessory = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->position = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = AccessoryPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Accessory object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AccessoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProductRelatedByProductId = null;
+ $this->aProductRelatedByAccessory = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AccessoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AccessoryPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AccessoryPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AccessoryPeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(AccessoryPeer::ACCESSORY)) {
+ $modifiedColumns[':p' . $index++] = '`ACCESSORY`';
+ }
+ if ($this->isColumnModified(AccessoryPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(AccessoryPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AccessoryPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `accessory` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`ACCESSORY`':
+ $stmt->bindValue($identifier, $this->accessory, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AccessoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getProductId();
+ break;
+ case 2:
+ return $this->getAccessory();
+ break;
+ case 3:
+ return $this->getPosition();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()] = true;
+ $keys = AccessoryPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getAccessory(),
+ $keys[3] => $this->getPosition(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aProductRelatedByProductId) {
+ $result['ProductRelatedByProductId'] = $this->aProductRelatedByProductId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aProductRelatedByAccessory) {
+ $result['ProductRelatedByAccessory'] = $this->aProductRelatedByAccessory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AccessoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setProductId($value);
+ break;
+ case 2:
+ $this->setAccessory($value);
+ break;
+ case 3:
+ $this->setPosition($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AccessoryPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAccessory($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AccessoryPeer::ID)) $criteria->add(AccessoryPeer::ID, $this->id);
+ if ($this->isColumnModified(AccessoryPeer::PRODUCT_ID)) $criteria->add(AccessoryPeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(AccessoryPeer::ACCESSORY)) $criteria->add(AccessoryPeer::ACCESSORY, $this->accessory);
+ if ($this->isColumnModified(AccessoryPeer::POSITION)) $criteria->add(AccessoryPeer::POSITION, $this->position);
+ if ($this->isColumnModified(AccessoryPeer::CREATED_AT)) $criteria->add(AccessoryPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AccessoryPeer::UPDATED_AT)) $criteria->add(AccessoryPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
+ $criteria->add(AccessoryPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Accessory (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setAccessory($this->getAccessory());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Accessory Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AccessoryPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AccessoryPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return Accessory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProductRelatedByProductId(Product $v = null)
+ {
+ 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;
+ }
+
+
+ /**
+ * Get the associated Product object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Product The associated Product object.
+ * @throws PropelException
+ */
+ public function getProductRelatedByProductId(PropelPDO $con = null)
+ {
+ 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->aProductRelatedByProductId;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return Accessory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProductRelatedByAccessory(Product $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->accessory = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProductRelatedByProductId = null;
+ $this->aProductRelatedByAccessory = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AccessoryPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAccessoryPeer.php b/core/lib/Thelia/Model/om/BaseAccessoryPeer.php
new file mode 100644
index 000000000..f9d5ee6e9
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAccessoryPeer.php
@@ -0,0 +1,1364 @@
+ array ('Id', 'ProductId', 'Accessory', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'accessory', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AccessoryPeer::ID, AccessoryPeer::PRODUCT_ID, AccessoryPeer::ACCESSORY, AccessoryPeer::POSITION, AccessoryPeer::CREATED_AT, AccessoryPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'ACCESSORY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'accessory', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AccessoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'Accessory' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'accessory' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ BasePeer::TYPE_COLNAME => array (AccessoryPeer::ID => 0, AccessoryPeer::PRODUCT_ID => 1, AccessoryPeer::ACCESSORY => 2, AccessoryPeer::POSITION => 3, AccessoryPeer::CREATED_AT => 4, AccessoryPeer::UPDATED_AT => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'ACCESSORY' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'accessory' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AccessoryPeer::getFieldNames($toType);
+ $key = isset(AccessoryPeer::$fieldKeys[$fromType][$name]) ? AccessoryPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AccessoryPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AccessoryPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AccessoryPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AccessoryPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AccessoryPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AccessoryPeer::ID);
+ $criteria->addSelectColumn(AccessoryPeer::PRODUCT_ID);
+ $criteria->addSelectColumn(AccessoryPeer::ACCESSORY);
+ $criteria->addSelectColumn(AccessoryPeer::POSITION);
+ $criteria->addSelectColumn(AccessoryPeer::CREATED_AT);
+ $criteria->addSelectColumn(AccessoryPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.ACCESSORY');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Accessory
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AccessoryPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AccessoryPeer::populateObjects(AccessoryPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AccessoryPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Accessory $obj A Accessory object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AccessoryPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Accessory object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Accessory) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Accessory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AccessoryPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Accessory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AccessoryPeer::$instances[$key])) {
+ return AccessoryPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AccessoryPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to accessory
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AccessoryPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AccessoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AccessoryPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Accessory object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AccessoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AccessoryPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AccessoryPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AccessoryPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AccessoryPeer::DATABASE_NAME)->getTable(AccessoryPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAccessoryPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAccessoryPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AccessoryTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AccessoryPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Accessory or Criteria object.
+ *
+ * @param mixed $values Criteria or Accessory object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Accessory object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Accessory or Criteria object.
+ *
+ * @param mixed $values Criteria or Accessory object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AccessoryPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AccessoryPeer::ID);
+ $value = $criteria->remove(AccessoryPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AccessoryPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Accessory object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the accessory table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ AccessoryPeer::clearInstancePool();
+ AccessoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Accessory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Accessory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AccessoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Accessory object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Accessory $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AccessoryPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AccessoryPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AccessoryPeer::DATABASE_NAME, AccessoryPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Accessory
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AccessoryPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
+ $criteria->add(AccessoryPeer::ID, $pk);
+
+ $v = AccessoryPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Accessory[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
+ $criteria->add(AccessoryPeer::ID, $pks, Criteria::IN);
+ $objs = AccessoryPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAccessoryPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAccessoryPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php
new file mode 100644
index 000000000..b1de88d0b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php
@@ -0,0 +1,653 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Accessory|Accessory[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AccessoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Accessory A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PRODUCT_ID`, `ACCESSORY`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `accessory` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Accessory();
+ $obj->hydrate($row);
+ AccessoryPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Accessory|Accessory[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Accessory[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AccessoryPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AccessoryPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AccessoryPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProductRelatedByProductId()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(AccessoryPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(AccessoryPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryPeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the accessory column
+ *
+ * Example usage:
+ *
+ * $query->filterByAccessory(1234); // WHERE accessory = 1234
+ * $query->filterByAccessory(array(12, 34)); // WHERE accessory IN (12, 34)
+ * $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.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function filterByAccessory($accessory = null, $comparison = null)
+ {
+ if (is_array($accessory)) {
+ $useMinMax = false;
+ if (isset($accessory['min'])) {
+ $this->addUsingAlias(AccessoryPeer::ACCESSORY, $accessory['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($accessory['max'])) {
+ $this->addUsingAlias(AccessoryPeer::ACCESSORY, $accessory['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryPeer::ACCESSORY, $accessory, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(AccessoryPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(AccessoryPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AccessoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AccessoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AccessoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AccessoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryPeer::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 AccessoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ 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
+ ->addUsingAlias(AccessoryPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProductRelatedByProductId() only accepts arguments of type Product or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 joinProductRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductRelatedByProductId');
+
+ // 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, 'ProductRelatedByProductId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductRelatedByProductId 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 useProductRelatedByProductIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->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(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 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
+ ->addUsingAlias(AccessoryPeer::ACCESSORY, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProductRelatedByAccessory() only accepts arguments of type Product or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 joinProductRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductRelatedByAccessory');
+
+ // 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, 'ProductRelatedByAccessory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductRelatedByAccessory 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 useProductRelatedByAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductRelatedByAccessory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductRelatedByAccessory', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Accessory $accessory Object to remove from the list of results
+ *
+ * @return AccessoryQuery The current query, for fluid interface
+ */
+ public function prune($accessory = null)
+ {
+ if ($accessory) {
+ $this->addUsingAlias(AccessoryPeer::ID, $accessory->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAddress.php b/core/lib/Thelia/Model/om/BaseAddress.php
new file mode 100644
index 000000000..75feacbd3
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAddress.php
@@ -0,0 +1,1843 @@
+id;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [customer_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerId()
+ {
+ return $this->customer_id;
+ }
+
+ /**
+ * Get the [customer_title_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerTitleId()
+ {
+ return $this->customer_title_id;
+ }
+
+ /**
+ * Get the [company] column value.
+ *
+ * @return string
+ */
+ public function getCompany()
+ {
+ return $this->company;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+ return $this->lastname;
+ }
+
+ /**
+ * Get the [address1] column value.
+ *
+ * @return string
+ */
+ public function getAddress1()
+ {
+ return $this->address1;
+ }
+
+ /**
+ * Get the [address2] column value.
+ *
+ * @return string
+ */
+ public function getAddress2()
+ {
+ return $this->address2;
+ }
+
+ /**
+ * Get the [address3] column value.
+ *
+ * @return string
+ */
+ public function getAddress3()
+ {
+ return $this->address3;
+ }
+
+ /**
+ * Get the [zipcode] column value.
+ *
+ * @return string
+ */
+ public function getZipcode()
+ {
+ return $this->zipcode;
+ }
+
+ /**
+ * Get the [city] column value.
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+ return $this->city;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [phone] column value.
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+ return $this->phone;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AddressPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = AddressPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [customer_id] column.
+ *
+ * @param int $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setCustomerId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_id !== $v) {
+ $this->customer_id = $v;
+ $this->modifiedColumns[] = AddressPeer::CUSTOMER_ID;
+ }
+
+ if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
+ $this->aCustomer = null;
+ }
+
+
+ return $this;
+ } // setCustomerId()
+
+ /**
+ * Set the value of [customer_title_id] column.
+ *
+ * @param int $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setCustomerTitleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_title_id !== $v) {
+ $this->customer_title_id = $v;
+ $this->modifiedColumns[] = AddressPeer::CUSTOMER_TITLE_ID;
+ }
+
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
+
+ return $this;
+ } // setCustomerTitleId()
+
+ /**
+ * Set the value of [company] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setCompany($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->company !== $v) {
+ $this->company = $v;
+ $this->modifiedColumns[] = AddressPeer::COMPANY;
+ }
+
+
+ return $this;
+ } // setCompany()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[] = AddressPeer::FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[] = AddressPeer::LASTNAME;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [address1] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setAddress1($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address1 !== $v) {
+ $this->address1 = $v;
+ $this->modifiedColumns[] = AddressPeer::ADDRESS1;
+ }
+
+
+ return $this;
+ } // setAddress1()
+
+ /**
+ * Set the value of [address2] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setAddress2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address2 !== $v) {
+ $this->address2 = $v;
+ $this->modifiedColumns[] = AddressPeer::ADDRESS2;
+ }
+
+
+ return $this;
+ } // setAddress2()
+
+ /**
+ * Set the value of [address3] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setAddress3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address3 !== $v) {
+ $this->address3 = $v;
+ $this->modifiedColumns[] = AddressPeer::ADDRESS3;
+ }
+
+
+ return $this;
+ } // setAddress3()
+
+ /**
+ * Set the value of [zipcode] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setZipcode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->zipcode !== $v) {
+ $this->zipcode = $v;
+ $this->modifiedColumns[] = AddressPeer::ZIPCODE;
+ }
+
+
+ return $this;
+ } // setZipcode()
+
+ /**
+ * Set the value of [city] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setCity($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->city !== $v) {
+ $this->city = $v;
+ $this->modifiedColumns[] = AddressPeer::CITY;
+ }
+
+
+ return $this;
+ } // setCity()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = AddressPeer::COUNTRY_ID;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Set the value of [phone] column.
+ *
+ * @param string $v new value
+ * @return Address The current object (for fluent API support)
+ */
+ public function setPhone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->phone !== $v) {
+ $this->phone = $v;
+ $this->modifiedColumns[] = AddressPeer::PHONE;
+ }
+
+
+ return $this;
+ } // setPhone()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Address The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AddressPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Address The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AddressPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->title = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->customer_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->customer_title_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->company = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->firstname = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->lastname = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->address1 = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->address2 = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->address3 = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
+ $this->zipcode = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
+ $this->city = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
+ $this->country_id = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null;
+ $this->phone = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
+ $this->created_at = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null;
+ $this->updated_at = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 16; // 16 = AddressPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Address object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AddressPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCustomer = null;
+ $this->aCustomerTitle = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AddressQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AddressPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AddressPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AddressPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AddressPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AddressPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(AddressPeer::CUSTOMER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CUSTOMER_ID`';
+ }
+ if ($this->isColumnModified(AddressPeer::CUSTOMER_TITLE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CUSTOMER_TITLE_ID`';
+ }
+ if ($this->isColumnModified(AddressPeer::COMPANY)) {
+ $modifiedColumns[':p' . $index++] = '`COMPANY`';
+ }
+ if ($this->isColumnModified(AddressPeer::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`FIRSTNAME`';
+ }
+ if ($this->isColumnModified(AddressPeer::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`LASTNAME`';
+ }
+ if ($this->isColumnModified(AddressPeer::ADDRESS1)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS1`';
+ }
+ if ($this->isColumnModified(AddressPeer::ADDRESS2)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS2`';
+ }
+ if ($this->isColumnModified(AddressPeer::ADDRESS3)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS3`';
+ }
+ if ($this->isColumnModified(AddressPeer::ZIPCODE)) {
+ $modifiedColumns[':p' . $index++] = '`ZIPCODE`';
+ }
+ if ($this->isColumnModified(AddressPeer::CITY)) {
+ $modifiedColumns[':p' . $index++] = '`CITY`';
+ }
+ if ($this->isColumnModified(AddressPeer::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`';
+ }
+ if ($this->isColumnModified(AddressPeer::PHONE)) {
+ $modifiedColumns[':p' . $index++] = '`PHONE`';
+ }
+ if ($this->isColumnModified(AddressPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AddressPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `address` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`CUSTOMER_ID`':
+ $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
+ break;
+ case '`CUSTOMER_TITLE_ID`':
+ $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
+ break;
+ case '`COMPANY`':
+ $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR);
+ break;
+ case '`FIRSTNAME`':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case '`LASTNAME`':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS1`':
+ $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS2`':
+ $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS3`':
+ $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
+ break;
+ case '`ZIPCODE`':
+ $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
+ break;
+ case '`CITY`':
+ $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
+ break;
+ case '`COUNTRY_ID`':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case '`PHONE`':
+ $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getTitle();
+ break;
+ case 2:
+ return $this->getCustomerId();
+ break;
+ case 3:
+ return $this->getCustomerTitleId();
+ break;
+ case 4:
+ return $this->getCompany();
+ break;
+ case 5:
+ return $this->getFirstname();
+ break;
+ case 6:
+ return $this->getLastname();
+ break;
+ case 7:
+ return $this->getAddress1();
+ break;
+ case 8:
+ return $this->getAddress2();
+ break;
+ case 9:
+ return $this->getAddress3();
+ break;
+ case 10:
+ return $this->getZipcode();
+ break;
+ case 11:
+ return $this->getCity();
+ break;
+ case 12:
+ return $this->getCountryId();
+ break;
+ case 13:
+ return $this->getPhone();
+ break;
+ case 14:
+ return $this->getCreatedAt();
+ break;
+ case 15:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Address'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Address'][$this->getPrimaryKey()] = true;
+ $keys = AddressPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTitle(),
+ $keys[2] => $this->getCustomerId(),
+ $keys[3] => $this->getCustomerTitleId(),
+ $keys[4] => $this->getCompany(),
+ $keys[5] => $this->getFirstname(),
+ $keys[6] => $this->getLastname(),
+ $keys[7] => $this->getAddress1(),
+ $keys[8] => $this->getAddress2(),
+ $keys[9] => $this->getAddress3(),
+ $keys[10] => $this->getZipcode(),
+ $keys[11] => $this->getCity(),
+ $keys[12] => $this->getCountryId(),
+ $keys[13] => $this->getPhone(),
+ $keys[14] => $this->getCreatedAt(),
+ $keys[15] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCustomer) {
+ $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setTitle($value);
+ break;
+ case 2:
+ $this->setCustomerId($value);
+ break;
+ case 3:
+ $this->setCustomerTitleId($value);
+ break;
+ case 4:
+ $this->setCompany($value);
+ break;
+ case 5:
+ $this->setFirstname($value);
+ break;
+ case 6:
+ $this->setLastname($value);
+ break;
+ case 7:
+ $this->setAddress1($value);
+ break;
+ case 8:
+ $this->setAddress2($value);
+ break;
+ case 9:
+ $this->setAddress3($value);
+ break;
+ case 10:
+ $this->setZipcode($value);
+ break;
+ case 11:
+ $this->setCity($value);
+ break;
+ case 12:
+ $this->setCountryId($value);
+ break;
+ case 13:
+ $this->setPhone($value);
+ break;
+ case 14:
+ $this->setCreatedAt($value);
+ break;
+ case 15:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AddressPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCustomerTitleId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCompany($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setFirstname($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setLastname($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setAddress1($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setAddress2($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setAddress3($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setZipcode($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCity($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCountryId($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setPhone($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AddressPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AddressPeer::ID)) $criteria->add(AddressPeer::ID, $this->id);
+ if ($this->isColumnModified(AddressPeer::TITLE)) $criteria->add(AddressPeer::TITLE, $this->title);
+ if ($this->isColumnModified(AddressPeer::CUSTOMER_ID)) $criteria->add(AddressPeer::CUSTOMER_ID, $this->customer_id);
+ if ($this->isColumnModified(AddressPeer::CUSTOMER_TITLE_ID)) $criteria->add(AddressPeer::CUSTOMER_TITLE_ID, $this->customer_title_id);
+ if ($this->isColumnModified(AddressPeer::COMPANY)) $criteria->add(AddressPeer::COMPANY, $this->company);
+ if ($this->isColumnModified(AddressPeer::FIRSTNAME)) $criteria->add(AddressPeer::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(AddressPeer::LASTNAME)) $criteria->add(AddressPeer::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(AddressPeer::ADDRESS1)) $criteria->add(AddressPeer::ADDRESS1, $this->address1);
+ if ($this->isColumnModified(AddressPeer::ADDRESS2)) $criteria->add(AddressPeer::ADDRESS2, $this->address2);
+ if ($this->isColumnModified(AddressPeer::ADDRESS3)) $criteria->add(AddressPeer::ADDRESS3, $this->address3);
+ if ($this->isColumnModified(AddressPeer::ZIPCODE)) $criteria->add(AddressPeer::ZIPCODE, $this->zipcode);
+ if ($this->isColumnModified(AddressPeer::CITY)) $criteria->add(AddressPeer::CITY, $this->city);
+ if ($this->isColumnModified(AddressPeer::COUNTRY_ID)) $criteria->add(AddressPeer::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(AddressPeer::PHONE)) $criteria->add(AddressPeer::PHONE, $this->phone);
+ if ($this->isColumnModified(AddressPeer::CREATED_AT)) $criteria->add(AddressPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AddressPeer::UPDATED_AT)) $criteria->add(AddressPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AddressPeer::DATABASE_NAME);
+ $criteria->add(AddressPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Address (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setCustomerId($this->getCustomerId());
+ $copyObj->setCustomerTitleId($this->getCustomerTitleId());
+ $copyObj->setCompany($this->getCompany());
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setAddress1($this->getAddress1());
+ $copyObj->setAddress2($this->getAddress2());
+ $copyObj->setAddress3($this->getAddress3());
+ $copyObj->setZipcode($this->getZipcode());
+ $copyObj->setCity($this->getCity());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setPhone($this->getPhone());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Address Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AddressPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AddressPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Customer object.
+ *
+ * @param Customer $v
+ * @return Address The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomer(Customer $v = null)
+ {
+ 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;
+ }
+
+
+ /**
+ * Get the associated Customer object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Customer The associated Customer object.
+ * @throws PropelException
+ */
+ public function getCustomer(PropelPDO $con = null)
+ {
+ 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->aCustomer;
+ }
+
+ /**
+ * Declares an association between this object and a CustomerTitle object.
+ *
+ * @param CustomerTitle $v
+ * @return Address The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomerTitle(CustomerTitle $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->title = null;
+ $this->customer_id = null;
+ $this->customer_title_id = null;
+ $this->company = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->address1 = null;
+ $this->address2 = null;
+ $this->address3 = null;
+ $this->zipcode = null;
+ $this->city = null;
+ $this->country_id = null;
+ $this->phone = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCustomer = null;
+ $this->aCustomerTitle = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AddressPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAddressPeer.php b/core/lib/Thelia/Model/om/BaseAddressPeer.php
new file mode 100644
index 000000000..7ffed74ba
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAddressPeer.php
@@ -0,0 +1,1471 @@
+ array ('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AddressPeer::ID, AddressPeer::TITLE, AddressPeer::CUSTOMER_ID, AddressPeer::CUSTOMER_TITLE_ID, AddressPeer::COMPANY, AddressPeer::FIRSTNAME, AddressPeer::LASTNAME, AddressPeer::ADDRESS1, AddressPeer::ADDRESS2, AddressPeer::ADDRESS3, AddressPeer::ZIPCODE, AddressPeer::CITY, AddressPeer::COUNTRY_ID, AddressPeer::PHONE, AddressPeer::CREATED_AT, AddressPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AddressPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'createdAt' => 14, 'updatedAt' => 15, ),
+ BasePeer::TYPE_COLNAME => array (AddressPeer::ID => 0, AddressPeer::TITLE => 1, AddressPeer::CUSTOMER_ID => 2, AddressPeer::CUSTOMER_TITLE_ID => 3, AddressPeer::COMPANY => 4, AddressPeer::FIRSTNAME => 5, AddressPeer::LASTNAME => 6, AddressPeer::ADDRESS1 => 7, AddressPeer::ADDRESS2 => 8, AddressPeer::ADDRESS3 => 9, AddressPeer::ZIPCODE => 10, AddressPeer::CITY => 11, AddressPeer::COUNTRY_ID => 12, AddressPeer::PHONE => 13, AddressPeer::CREATED_AT => 14, AddressPeer::UPDATED_AT => 15, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'created_at' => 14, 'updated_at' => 15, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AddressPeer::getFieldNames($toType);
+ $key = isset(AddressPeer::$fieldKeys[$fromType][$name]) ? AddressPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AddressPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AddressPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AddressPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AddressPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AddressPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AddressPeer::ID);
+ $criteria->addSelectColumn(AddressPeer::TITLE);
+ $criteria->addSelectColumn(AddressPeer::CUSTOMER_ID);
+ $criteria->addSelectColumn(AddressPeer::CUSTOMER_TITLE_ID);
+ $criteria->addSelectColumn(AddressPeer::COMPANY);
+ $criteria->addSelectColumn(AddressPeer::FIRSTNAME);
+ $criteria->addSelectColumn(AddressPeer::LASTNAME);
+ $criteria->addSelectColumn(AddressPeer::ADDRESS1);
+ $criteria->addSelectColumn(AddressPeer::ADDRESS2);
+ $criteria->addSelectColumn(AddressPeer::ADDRESS3);
+ $criteria->addSelectColumn(AddressPeer::ZIPCODE);
+ $criteria->addSelectColumn(AddressPeer::CITY);
+ $criteria->addSelectColumn(AddressPeer::COUNTRY_ID);
+ $criteria->addSelectColumn(AddressPeer::PHONE);
+ $criteria->addSelectColumn(AddressPeer::CREATED_AT);
+ $criteria->addSelectColumn(AddressPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_ID');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
+ $criteria->addSelectColumn($alias . '.COMPANY');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.ADDRESS1');
+ $criteria->addSelectColumn($alias . '.ADDRESS2');
+ $criteria->addSelectColumn($alias . '.ADDRESS3');
+ $criteria->addSelectColumn($alias . '.ZIPCODE');
+ $criteria->addSelectColumn($alias . '.CITY');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.PHONE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AddressPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Address
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AddressPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AddressPeer::populateObjects(AddressPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AddressPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Address $obj A Address object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AddressPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Address object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Address) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Address object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AddressPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Address Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AddressPeer::$instances[$key])) {
+ return AddressPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AddressPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to address
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AddressPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AddressPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AddressPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AddressPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Address object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AddressPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AddressPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AddressPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AddressPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AddressPeer::DATABASE_NAME)->getTable(AddressPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAddressPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAddressPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AddressTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AddressPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Address or Criteria object.
+ *
+ * @param mixed $values Criteria or Address object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Address object
+ }
+
+ if ($criteria->containsKey(AddressPeer::ID) && $criteria->keyContainsValue(AddressPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AddressPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Address or Criteria object.
+ *
+ * @param mixed $values Criteria or Address object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AddressPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AddressPeer::ID);
+ $value = $criteria->remove(AddressPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AddressPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AddressPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Address object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the address table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ AddressPeer::clearInstancePool();
+ AddressPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Address or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Address object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(AddressPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AddressPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Address object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Address $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AddressPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AddressPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AddressPeer::DATABASE_NAME, AddressPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Address
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AddressPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AddressPeer::DATABASE_NAME);
+ $criteria->add(AddressPeer::ID, $pk);
+
+ $v = AddressPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Address[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AddressPeer::DATABASE_NAME);
+ $criteria->add(AddressPeer::ID, $pks, Criteria::IN);
+ $objs = AddressPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAddressPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAddressPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAddressQuery.php b/core/lib/Thelia/Model/om/BaseAddressQuery.php
new file mode 100644
index 000000000..88ca88e7f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAddressQuery.php
@@ -0,0 +1,984 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Address|Address[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AddressPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Address A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `TITLE`, `CUSTOMER_ID`, `CUSTOMER_TITLE_ID`, `COMPANY`, `FIRSTNAME`, `LASTNAME`, `ADDRESS1`, `ADDRESS2`, `ADDRESS3`, `ZIPCODE`, `CITY`, `COUNTRY_ID`, `PHONE`, `CREATED_AT`, `UPDATED_AT` FROM `address` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Address();
+ $obj->hydrate($row);
+ AddressPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Address|Address[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Address[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AddressPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AddressPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AddressPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerId(1234); // WHERE customer_id = 1234
+ * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
+ * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
+ *
+ *
+ * @see filterByCustomer()
+ *
+ * @param mixed $customerId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerId($customerId = null, $comparison = null)
+ {
+ if (is_array($customerId)) {
+ $useMinMax = false;
+ if (isset($customerId['min'])) {
+ $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerId['max'])) {
+ $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_title_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
+ * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
+ * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
+ *
+ *
+ * @see filterByCustomerTitle()
+ *
+ * @param mixed $customerTitleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
+ {
+ if (is_array($customerTitleId)) {
+ $useMinMax = false;
+ if (isset($customerTitleId['min'])) {
+ $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerTitleId['max'])) {
+ $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the company column
+ *
+ * Example usage:
+ *
+ * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue'
+ * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
+ *
+ *
+ * @param string $company The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByCompany($company = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($company)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $company)) {
+ $company = str_replace('*', '%', $company);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::COMPANY, $company, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the address1 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue'
+ * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address1 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress1($address1 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address1)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address1)) {
+ $address1 = str_replace('*', '%', $address1);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::ADDRESS1, $address1, $comparison);
+ }
+
+ /**
+ * Filter the query on the address2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue'
+ * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address2 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress2($address2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address2)) {
+ $address2 = str_replace('*', '%', $address2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::ADDRESS2, $address2, $comparison);
+ }
+
+ /**
+ * Filter the query on the address3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue'
+ * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address3 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress3($address3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address3)) {
+ $address3 = str_replace('*', '%', $address3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::ADDRESS3, $address3, $comparison);
+ }
+
+ /**
+ * Filter the query on the zipcode column
+ *
+ * Example usage:
+ *
+ * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue'
+ * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
+ *
+ *
+ * @param string $zipcode The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByZipcode($zipcode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($zipcode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $zipcode)) {
+ $zipcode = str_replace('*', '%', $zipcode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::ZIPCODE, $zipcode, $comparison);
+ }
+
+ /**
+ * Filter the query on the city column
+ *
+ * Example usage:
+ *
+ * $query->filterByCity('fooValue'); // WHERE city = 'fooValue'
+ * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
+ *
+ *
+ * @param string $city The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByCity($city = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($city)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $city)) {
+ $city = str_replace('*', '%', $city);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::CITY, $city, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the phone column
+ *
+ * Example usage:
+ *
+ * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
+ * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
+ *
+ *
+ * @param string $phone The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByPhone($phone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($phone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $phone)) {
+ $phone = str_replace('*', '%', $phone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::PHONE, $phone, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Customer object
+ *
+ * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AddressQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCustomer($customer, $comparison = null)
+ {
+ if ($customer instanceof Customer) {
+ return $this
+ ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->getId(), $comparison);
+ } elseif ($customer instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Customer relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Customer');
+
+ // 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, 'Customer');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Customer relation Customer 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\CustomerQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCustomer($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
+ }
+
+ /**
+ * 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 AddressQuery 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(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
+ } elseif ($customerTitle instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AddressPeer::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 AddressQuery 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');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Address $address Object to remove from the list of results
+ *
+ * @return AddressQuery The current query, for fluid interface
+ */
+ public function prune($address = null)
+ {
+ if ($address) {
+ $this->addUsingAlias(AddressPeer::ID, $address->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAdmin.php b/core/lib/Thelia/Model/om/BaseAdmin.php
new file mode 100644
index 000000000..4937b7d42
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdmin.php
@@ -0,0 +1,1591 @@
+id;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+ return $this->lastname;
+ }
+
+ /**
+ * Get the [login] column value.
+ *
+ * @return string
+ */
+ public function getLogin()
+ {
+ return $this->login;
+ }
+
+ /**
+ * Get the [password] column value.
+ *
+ * @return string
+ */
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ /**
+ * Get the [algo] column value.
+ *
+ * @return string
+ */
+ public function getAlgo()
+ {
+ return $this->algo;
+ }
+
+ /**
+ * Get the [salt] column value.
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+ return $this->salt;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AdminPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[] = AdminPeer::FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[] = AdminPeer::LASTNAME;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [login] column.
+ *
+ * @param string $v new value
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setLogin($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->login !== $v) {
+ $this->login = $v;
+ $this->modifiedColumns[] = AdminPeer::LOGIN;
+ }
+
+
+ return $this;
+ } // setLogin()
+
+ /**
+ * Set the value of [password] column.
+ *
+ * @param string $v new value
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setPassword($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->password !== $v) {
+ $this->password = $v;
+ $this->modifiedColumns[] = AdminPeer::PASSWORD;
+ }
+
+
+ return $this;
+ } // setPassword()
+
+ /**
+ * Set the value of [algo] column.
+ *
+ * @param string $v new value
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setAlgo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->algo !== $v) {
+ $this->algo = $v;
+ $this->modifiedColumns[] = AdminPeer::ALGO;
+ }
+
+
+ return $this;
+ } // setAlgo()
+
+ /**
+ * Set the value of [salt] column.
+ *
+ * @param string $v new value
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setSalt($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->salt !== $v) {
+ $this->salt = $v;
+ $this->modifiedColumns[] = AdminPeer::SALT;
+ }
+
+
+ return $this;
+ } // setSalt()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AdminPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Admin The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AdminPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->firstname = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->lastname = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->login = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->password = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->algo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->salt = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = AdminPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Admin object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AdminPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAdminGroups = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AdminQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AdminPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AdminPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AdminPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AdminPeer::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`FIRSTNAME`';
+ }
+ if ($this->isColumnModified(AdminPeer::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`LASTNAME`';
+ }
+ if ($this->isColumnModified(AdminPeer::LOGIN)) {
+ $modifiedColumns[':p' . $index++] = '`LOGIN`';
+ }
+ if ($this->isColumnModified(AdminPeer::PASSWORD)) {
+ $modifiedColumns[':p' . $index++] = '`PASSWORD`';
+ }
+ if ($this->isColumnModified(AdminPeer::ALGO)) {
+ $modifiedColumns[':p' . $index++] = '`ALGO`';
+ }
+ if ($this->isColumnModified(AdminPeer::SALT)) {
+ $modifiedColumns[':p' . $index++] = '`SALT`';
+ }
+ if ($this->isColumnModified(AdminPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AdminPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `admin` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`FIRSTNAME`':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case '`LASTNAME`':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case '`LOGIN`':
+ $stmt->bindValue($identifier, $this->login, PDO::PARAM_STR);
+ break;
+ case '`PASSWORD`':
+ $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR);
+ break;
+ case '`ALGO`':
+ $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR);
+ break;
+ case '`SALT`':
+ $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AdminPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getFirstname();
+ break;
+ case 2:
+ return $this->getLastname();
+ break;
+ case 3:
+ return $this->getLogin();
+ break;
+ case 4:
+ return $this->getPassword();
+ break;
+ case 5:
+ return $this->getAlgo();
+ break;
+ case 6:
+ return $this->getSalt();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Admin'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Admin'][$this->getPrimaryKey()] = true;
+ $keys = AdminPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFirstname(),
+ $keys[2] => $this->getLastname(),
+ $keys[3] => $this->getLogin(),
+ $keys[4] => $this->getPassword(),
+ $keys[5] => $this->getAlgo(),
+ $keys[6] => $this->getSalt(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collAdminGroups) {
+ $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AdminPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setFirstname($value);
+ break;
+ case 2:
+ $this->setLastname($value);
+ break;
+ case 3:
+ $this->setLogin($value);
+ break;
+ case 4:
+ $this->setPassword($value);
+ break;
+ case 5:
+ $this->setAlgo($value);
+ break;
+ case 6:
+ $this->setSalt($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AdminPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFirstname($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLastname($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setLogin($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPassword($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setAlgo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setSalt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AdminPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AdminPeer::ID)) $criteria->add(AdminPeer::ID, $this->id);
+ if ($this->isColumnModified(AdminPeer::FIRSTNAME)) $criteria->add(AdminPeer::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(AdminPeer::LASTNAME)) $criteria->add(AdminPeer::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(AdminPeer::LOGIN)) $criteria->add(AdminPeer::LOGIN, $this->login);
+ if ($this->isColumnModified(AdminPeer::PASSWORD)) $criteria->add(AdminPeer::PASSWORD, $this->password);
+ if ($this->isColumnModified(AdminPeer::ALGO)) $criteria->add(AdminPeer::ALGO, $this->algo);
+ if ($this->isColumnModified(AdminPeer::SALT)) $criteria->add(AdminPeer::SALT, $this->salt);
+ if ($this->isColumnModified(AdminPeer::CREATED_AT)) $criteria->add(AdminPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AdminPeer::UPDATED_AT)) $criteria->add(AdminPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AdminPeer::DATABASE_NAME);
+ $criteria->add(AdminPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Admin (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setLogin($this->getLogin());
+ $copyObj->setPassword($this->getPassword());
+ $copyObj->setAlgo($this->getAlgo());
+ $copyObj->setSalt($this->getSalt());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getAdminGroups() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAdminGroup($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Admin Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AdminPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AdminPeer();
+ }
+
+ 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.
+ *
+ * @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 getAdminGroups($criteria = null, PropelPDO $con = 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 {
+ return count($this->collAdminGroups);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * @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->setAdmin(null);
+ }
+ }
+
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->login = null;
+ $this->password = null;
+ $this->algo = null;
+ $this->salt = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collAdminGroups) {
+ foreach ($this->collAdminGroups as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collAdminGroups instanceof PropelCollection) {
+ $this->collAdminGroups->clearIterator();
+ }
+ $this->collAdminGroups = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AdminPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAdminGroup.php b/core/lib/Thelia/Model/om/BaseAdminGroup.php
new file mode 100644
index 000000000..9827859c4
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdminGroup.php
@@ -0,0 +1,1238 @@
+id;
+ }
+
+ /**
+ * Get the [group_id] column value.
+ *
+ * @return int
+ */
+ public function getGroupId()
+ {
+ return $this->group_id;
+ }
+
+ /**
+ * Get the [admin_id] column value.
+ *
+ * @return int
+ */
+ public function getAdminId()
+ {
+ return $this->admin_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return AdminGroup The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AdminGroupPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [group_id] column.
+ *
+ * @param int $v new value
+ * @return AdminGroup The current object (for fluent API support)
+ */
+ public function setGroupId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->group_id !== $v) {
+ $this->group_id = $v;
+ $this->modifiedColumns[] = AdminGroupPeer::GROUP_ID;
+ }
+
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
+
+ return $this;
+ } // setGroupId()
+
+ /**
+ * Set the value of [admin_id] column.
+ *
+ * @param int $v new value
+ * @return AdminGroup The current object (for fluent API support)
+ */
+ public function setAdminId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->admin_id !== $v) {
+ $this->admin_id = $v;
+ $this->modifiedColumns[] = AdminGroupPeer::ADMIN_ID;
+ }
+
+ if ($this->aAdmin !== null && $this->aAdmin->getId() !== $v) {
+ $this->aAdmin = null;
+ }
+
+
+ return $this;
+ } // setAdminId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AdminGroup The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AdminGroupPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AdminGroup The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AdminGroupPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->group_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->admin_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = AdminGroupPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating AdminGroup object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AdminGroupPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aGroup = null;
+ $this->aAdmin = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AdminGroupQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AdminGroupPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AdminGroupPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminGroupPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AdminGroupPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AdminGroupPeer::GROUP_ID)) {
+ $modifiedColumns[':p' . $index++] = '`GROUP_ID`';
+ }
+ if ($this->isColumnModified(AdminGroupPeer::ADMIN_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ADMIN_ID`';
+ }
+ if ($this->isColumnModified(AdminGroupPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AdminGroupPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `admin_group` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`GROUP_ID`':
+ $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT);
+ break;
+ case '`ADMIN_ID`':
+ $stmt->bindValue($identifier, $this->admin_id, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AdminGroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getGroupId();
+ break;
+ case 2:
+ return $this->getAdminId();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AdminGroup'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AdminGroup'][$this->getPrimaryKey()] = true;
+ $keys = AdminGroupPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getGroupId(),
+ $keys[2] => $this->getAdminId(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aAdmin) {
+ $result['Admin'] = $this->aAdmin->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AdminGroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setGroupId($value);
+ break;
+ case 2:
+ $this->setAdminId($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AdminGroupPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAdminId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AdminGroupPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AdminGroupPeer::ID)) $criteria->add(AdminGroupPeer::ID, $this->id);
+ if ($this->isColumnModified(AdminGroupPeer::GROUP_ID)) $criteria->add(AdminGroupPeer::GROUP_ID, $this->group_id);
+ if ($this->isColumnModified(AdminGroupPeer::ADMIN_ID)) $criteria->add(AdminGroupPeer::ADMIN_ID, $this->admin_id);
+ if ($this->isColumnModified(AdminGroupPeer::CREATED_AT)) $criteria->add(AdminGroupPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AdminGroupPeer::UPDATED_AT)) $criteria->add(AdminGroupPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AdminGroupPeer::DATABASE_NAME);
+ $criteria->add(AdminGroupPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of AdminGroup (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setGroupId($this->getGroupId());
+ $copyObj->setAdminId($this->getAdminId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return AdminGroup Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AdminGroupPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AdminGroupPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Group object.
+ *
+ * @param Group $v
+ * @return AdminGroup The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setGroup(Group $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->group_id = null;
+ $this->admin_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aGroup = null;
+ $this->aAdmin = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AdminGroupPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php b/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php
new file mode 100644
index 000000000..6488ae3ab
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php
@@ -0,0 +1,1416 @@
+ array ('Id', 'GroupId', 'AdminId', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'groupId', 'adminId', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AdminGroupPeer::ID, AdminGroupPeer::GROUP_ID, AdminGroupPeer::ADMIN_ID, AdminGroupPeer::CREATED_AT, AdminGroupPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GROUP_ID', 'ADMIN_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'group_id', 'admin_id', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AdminGroupPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'GroupId' => 1, 'AdminId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'groupId' => 1, 'adminId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (AdminGroupPeer::ID => 0, AdminGroupPeer::GROUP_ID => 1, AdminGroupPeer::ADMIN_ID => 2, AdminGroupPeer::CREATED_AT => 3, AdminGroupPeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GROUP_ID' => 1, 'ADMIN_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'group_id' => 1, 'admin_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AdminGroupPeer::getFieldNames($toType);
+ $key = isset(AdminGroupPeer::$fieldKeys[$fromType][$name]) ? AdminGroupPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AdminGroupPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AdminGroupPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AdminGroupPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AdminGroupPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AdminGroupPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AdminGroupPeer::ID);
+ $criteria->addSelectColumn(AdminGroupPeer::GROUP_ID);
+ $criteria->addSelectColumn(AdminGroupPeer::ADMIN_ID);
+ $criteria->addSelectColumn(AdminGroupPeer::CREATED_AT);
+ $criteria->addSelectColumn(AdminGroupPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.GROUP_ID');
+ $criteria->addSelectColumn($alias . '.ADMIN_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return AdminGroup
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AdminGroupPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AdminGroupPeer::populateObjects(AdminGroupPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AdminGroupPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param AdminGroup $obj A AdminGroup object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AdminGroupPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A AdminGroup object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof AdminGroup) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AdminGroup object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AdminGroupPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return AdminGroup Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AdminGroupPeer::$instances[$key])) {
+ return AdminGroupPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AdminGroupPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to admin_group
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AdminGroupPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AdminGroupPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AdminGroupPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AdminGroup object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AdminGroupPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AdminGroupPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AdminGroupPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AdminGroupPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AdminGroupPeer::DATABASE_NAME)->getTable(AdminGroupPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAdminGroupPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAdminGroupPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AdminGroupTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AdminGroupPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AdminGroup or Criteria object.
+ *
+ * @param mixed $values Criteria or AdminGroup object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from AdminGroup object
+ }
+
+ if ($criteria->containsKey(AdminGroupPeer::ID) && $criteria->keyContainsValue(AdminGroupPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminGroupPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a AdminGroup or Criteria object.
+ *
+ * @param mixed $values Criteria or AdminGroup object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AdminGroupPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AdminGroupPeer::ID);
+ $value = $criteria->remove(AdminGroupPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AdminGroupPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME);
+ }
+
+ } else { // $values is AdminGroup object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the admin_group table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ AdminGroupPeer::clearInstancePool();
+ AdminGroupPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AdminGroup or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AdminGroup object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(AdminGroupPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AdminGroupPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given AdminGroup object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param AdminGroup $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AdminGroupPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AdminGroupPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AdminGroupPeer::DATABASE_NAME, AdminGroupPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return AdminGroup
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AdminGroupPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AdminGroupPeer::DATABASE_NAME);
+ $criteria->add(AdminGroupPeer::ID, $pk);
+
+ $v = AdminGroupPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return AdminGroup[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AdminGroupPeer::DATABASE_NAME);
+ $criteria->add(AdminGroupPeer::ID, $pks, Criteria::IN);
+ $objs = AdminGroupPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAdminGroupPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAdminGroupPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php
new file mode 100644
index 000000000..220fb9bb5
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php
@@ -0,0 +1,609 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return AdminGroup|AdminGroup[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AdminGroupPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AdminGroup A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `GROUP_ID`, `ADMIN_ID`, `CREATED_AT`, `UPDATED_AT` FROM `admin_group` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new AdminGroup();
+ $obj->hydrate($row);
+ AdminGroupPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AdminGroup|AdminGroup[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|AdminGroup[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AdminGroupPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AdminGroupPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AdminGroupPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the group_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByGroupId(1234); // WHERE group_id = 1234
+ * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34)
+ * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
+ *
+ *
+ * @see filterByGroup()
+ *
+ * @param mixed $groupId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByGroupId($groupId = null, $comparison = null)
+ {
+ if (is_array($groupId)) {
+ $useMinMax = false;
+ if (isset($groupId['min'])) {
+ $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($groupId['max'])) {
+ $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $groupId, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminId(1234); // WHERE admin_id = 1234
+ * $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34)
+ * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12
+ *
+ *
+ * @see filterByAdmin()
+ *
+ * @param mixed $adminId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByAdminId($adminId = null, $comparison = null)
+ {
+ if (is_array($adminId)) {
+ $useMinMax = false;
+ if (isset($adminId['min'])) {
+ $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($adminId['max'])) {
+ $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $adminId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AdminGroupPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AdminGroupPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Group object
+ *
+ * @param Group|PropelObjectCollection $group The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroup($group, $comparison = null)
+ {
+ if ($group instanceof Group) {
+ return $this
+ ->addUsingAlias(AdminGroupPeer::GROUP_ID, $group->getId(), $comparison);
+ } elseif ($group instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AdminGroupPeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Group 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 joinGroup($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Group');
+
+ // 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, 'Group');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Group relation Group 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\GroupQuery A secondary query class using the current class as primary query
+ */
+ 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
+ *
+ * @param AdminGroup $adminGroup Object to remove from the list of results
+ *
+ * @return AdminGroupQuery The current query, for fluid interface
+ */
+ public function prune($adminGroup = null)
+ {
+ if ($adminGroup) {
+ $this->addUsingAlias(AdminGroupPeer::ID, $adminGroup->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAdminLog.php b/core/lib/Thelia/Model/om/BaseAdminLog.php
new file mode 100644
index 000000000..189b957ba
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdminLog.php
@@ -0,0 +1,1211 @@
+id;
+ }
+
+ /**
+ * Get the [admin_login] column value.
+ *
+ * @return string
+ */
+ public function getAdminLogin()
+ {
+ return $this->admin_login;
+ }
+
+ /**
+ * Get the [admin_firstname] column value.
+ *
+ * @return string
+ */
+ public function getAdminFirstname()
+ {
+ return $this->admin_firstname;
+ }
+
+ /**
+ * Get the [admin_lastname] column value.
+ *
+ * @return string
+ */
+ public function getAdminLastname()
+ {
+ return $this->admin_lastname;
+ }
+
+ /**
+ * Get the [action] column value.
+ *
+ * @return string
+ */
+ public function getAction()
+ {
+ return $this->action;
+ }
+
+ /**
+ * Get the [request] column value.
+ *
+ * @return string
+ */
+ public function getRequest()
+ {
+ return $this->request;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return AdminLog The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AdminLogPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [admin_login] column.
+ *
+ * @param string $v new value
+ * @return AdminLog The current object (for fluent API support)
+ */
+ public function setAdminLogin($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->admin_login !== $v) {
+ $this->admin_login = $v;
+ $this->modifiedColumns[] = AdminLogPeer::ADMIN_LOGIN;
+ }
+
+
+ return $this;
+ } // setAdminLogin()
+
+ /**
+ * Set the value of [admin_firstname] column.
+ *
+ * @param string $v new value
+ * @return AdminLog The current object (for fluent API support)
+ */
+ public function setAdminFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->admin_firstname !== $v) {
+ $this->admin_firstname = $v;
+ $this->modifiedColumns[] = AdminLogPeer::ADMIN_FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setAdminFirstname()
+
+ /**
+ * Set the value of [admin_lastname] column.
+ *
+ * @param string $v new value
+ * @return AdminLog The current object (for fluent API support)
+ */
+ public function setAdminLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->admin_lastname !== $v) {
+ $this->admin_lastname = $v;
+ $this->modifiedColumns[] = AdminLogPeer::ADMIN_LASTNAME;
+ }
+
+
+ return $this;
+ } // setAdminLastname()
+
+ /**
+ * Set the value of [action] column.
+ *
+ * @param string $v new value
+ * @return AdminLog The current object (for fluent API support)
+ */
+ public function setAction($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->action !== $v) {
+ $this->action = $v;
+ $this->modifiedColumns[] = AdminLogPeer::ACTION;
+ }
+
+
+ return $this;
+ } // setAction()
+
+ /**
+ * Set the value of [request] column.
+ *
+ * @param string $v new value
+ * @return AdminLog The current object (for fluent API support)
+ */
+ public function setRequest($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->request !== $v) {
+ $this->request = $v;
+ $this->modifiedColumns[] = AdminLogPeer::REQUEST;
+ }
+
+
+ return $this;
+ } // setRequest()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AdminLog The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AdminLogPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AdminLog The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AdminLogPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->admin_login = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->admin_firstname = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->admin_lastname = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->action = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->request = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = AdminLogPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating AdminLog object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AdminLogPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AdminLogQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AdminLogPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AdminLogPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminLogPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AdminLogPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AdminLogPeer::ADMIN_LOGIN)) {
+ $modifiedColumns[':p' . $index++] = '`ADMIN_LOGIN`';
+ }
+ if ($this->isColumnModified(AdminLogPeer::ADMIN_FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`ADMIN_FIRSTNAME`';
+ }
+ if ($this->isColumnModified(AdminLogPeer::ADMIN_LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`ADMIN_LASTNAME`';
+ }
+ if ($this->isColumnModified(AdminLogPeer::ACTION)) {
+ $modifiedColumns[':p' . $index++] = '`ACTION`';
+ }
+ if ($this->isColumnModified(AdminLogPeer::REQUEST)) {
+ $modifiedColumns[':p' . $index++] = '`REQUEST`';
+ }
+ if ($this->isColumnModified(AdminLogPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AdminLogPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `admin_log` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`ADMIN_LOGIN`':
+ $stmt->bindValue($identifier, $this->admin_login, PDO::PARAM_STR);
+ break;
+ case '`ADMIN_FIRSTNAME`':
+ $stmt->bindValue($identifier, $this->admin_firstname, PDO::PARAM_STR);
+ break;
+ case '`ADMIN_LASTNAME`':
+ $stmt->bindValue($identifier, $this->admin_lastname, PDO::PARAM_STR);
+ break;
+ case '`ACTION`':
+ $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR);
+ break;
+ case '`REQUEST`':
+ $stmt->bindValue($identifier, $this->request, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ if (($retval = AdminLogPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AdminLogPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getAdminLogin();
+ break;
+ case 2:
+ return $this->getAdminFirstname();
+ break;
+ case 3:
+ return $this->getAdminLastname();
+ break;
+ case 4:
+ return $this->getAction();
+ break;
+ case 5:
+ return $this->getRequest();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
+ {
+ if (isset($alreadyDumpedObjects['AdminLog'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AdminLog'][$this->getPrimaryKey()] = true;
+ $keys = AdminLogPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAdminLogin(),
+ $keys[2] => $this->getAdminFirstname(),
+ $keys[3] => $this->getAdminLastname(),
+ $keys[4] => $this->getAction(),
+ $keys[5] => $this->getRequest(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AdminLogPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setAdminLogin($value);
+ break;
+ case 2:
+ $this->setAdminFirstname($value);
+ break;
+ case 3:
+ $this->setAdminLastname($value);
+ break;
+ case 4:
+ $this->setAction($value);
+ break;
+ case 5:
+ $this->setRequest($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AdminLogPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAdminLogin($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAdminFirstname($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setAdminLastname($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setAction($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setRequest($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AdminLogPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AdminLogPeer::ID)) $criteria->add(AdminLogPeer::ID, $this->id);
+ if ($this->isColumnModified(AdminLogPeer::ADMIN_LOGIN)) $criteria->add(AdminLogPeer::ADMIN_LOGIN, $this->admin_login);
+ if ($this->isColumnModified(AdminLogPeer::ADMIN_FIRSTNAME)) $criteria->add(AdminLogPeer::ADMIN_FIRSTNAME, $this->admin_firstname);
+ if ($this->isColumnModified(AdminLogPeer::ADMIN_LASTNAME)) $criteria->add(AdminLogPeer::ADMIN_LASTNAME, $this->admin_lastname);
+ if ($this->isColumnModified(AdminLogPeer::ACTION)) $criteria->add(AdminLogPeer::ACTION, $this->action);
+ if ($this->isColumnModified(AdminLogPeer::REQUEST)) $criteria->add(AdminLogPeer::REQUEST, $this->request);
+ if ($this->isColumnModified(AdminLogPeer::CREATED_AT)) $criteria->add(AdminLogPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AdminLogPeer::UPDATED_AT)) $criteria->add(AdminLogPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AdminLogPeer::DATABASE_NAME);
+ $criteria->add(AdminLogPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of AdminLog (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAdminLogin($this->getAdminLogin());
+ $copyObj->setAdminFirstname($this->getAdminFirstname());
+ $copyObj->setAdminLastname($this->getAdminLastname());
+ $copyObj->setAction($this->getAction());
+ $copyObj->setRequest($this->getRequest());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return AdminLog Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AdminLogPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AdminLogPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->admin_login = null;
+ $this->admin_firstname = null;
+ $this->admin_lastname = null;
+ $this->action = null;
+ $this->request = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AdminLogPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAdminLogPeer.php b/core/lib/Thelia/Model/om/BaseAdminLogPeer.php
new file mode 100644
index 000000000..c4c775b06
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdminLogPeer.php
@@ -0,0 +1,798 @@
+ array ('Id', 'AdminLogin', 'AdminFirstname', 'AdminLastname', 'Action', 'Request', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'adminLogin', 'adminFirstname', 'adminLastname', 'action', 'request', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AdminLogPeer::ID, AdminLogPeer::ADMIN_LOGIN, AdminLogPeer::ADMIN_FIRSTNAME, AdminLogPeer::ADMIN_LASTNAME, AdminLogPeer::ACTION, AdminLogPeer::REQUEST, AdminLogPeer::CREATED_AT, AdminLogPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ADMIN_LOGIN', 'ADMIN_FIRSTNAME', 'ADMIN_LASTNAME', 'ACTION', 'REQUEST', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'admin_login', 'admin_firstname', 'admin_lastname', 'action', 'request', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AdminLogPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AdminLogin' => 1, 'AdminFirstname' => 2, 'AdminLastname' => 3, 'Action' => 4, 'Request' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'adminLogin' => 1, 'adminFirstname' => 2, 'adminLastname' => 3, 'action' => 4, 'request' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (AdminLogPeer::ID => 0, AdminLogPeer::ADMIN_LOGIN => 1, AdminLogPeer::ADMIN_FIRSTNAME => 2, AdminLogPeer::ADMIN_LASTNAME => 3, AdminLogPeer::ACTION => 4, AdminLogPeer::REQUEST => 5, AdminLogPeer::CREATED_AT => 6, AdminLogPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ADMIN_LOGIN' => 1, 'ADMIN_FIRSTNAME' => 2, 'ADMIN_LASTNAME' => 3, 'ACTION' => 4, 'REQUEST' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'admin_login' => 1, 'admin_firstname' => 2, 'admin_lastname' => 3, 'action' => 4, 'request' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AdminLogPeer::getFieldNames($toType);
+ $key = isset(AdminLogPeer::$fieldKeys[$fromType][$name]) ? AdminLogPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AdminLogPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AdminLogPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AdminLogPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AdminLogPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AdminLogPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AdminLogPeer::ID);
+ $criteria->addSelectColumn(AdminLogPeer::ADMIN_LOGIN);
+ $criteria->addSelectColumn(AdminLogPeer::ADMIN_FIRSTNAME);
+ $criteria->addSelectColumn(AdminLogPeer::ADMIN_LASTNAME);
+ $criteria->addSelectColumn(AdminLogPeer::ACTION);
+ $criteria->addSelectColumn(AdminLogPeer::REQUEST);
+ $criteria->addSelectColumn(AdminLogPeer::CREATED_AT);
+ $criteria->addSelectColumn(AdminLogPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ADMIN_LOGIN');
+ $criteria->addSelectColumn($alias . '.ADMIN_FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.ADMIN_LASTNAME');
+ $criteria->addSelectColumn($alias . '.ACTION');
+ $criteria->addSelectColumn($alias . '.REQUEST');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(AdminLogPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ AdminLogPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(AdminLogPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return AdminLog
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AdminLogPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AdminLogPeer::populateObjects(AdminLogPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AdminLogPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminLogPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param AdminLog $obj A AdminLog object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AdminLogPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A AdminLog object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof AdminLog) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AdminLog object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AdminLogPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return AdminLog Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AdminLogPeer::$instances[$key])) {
+ return AdminLogPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AdminLogPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to admin_log
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AdminLogPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AdminLogPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AdminLogPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AdminLogPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AdminLog object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AdminLogPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AdminLogPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AdminLogPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AdminLogPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AdminLogPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AdminLogPeer::DATABASE_NAME)->getTable(AdminLogPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAdminLogPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAdminLogPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AdminLogTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AdminLogPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AdminLog or Criteria object.
+ *
+ * @param mixed $values Criteria or AdminLog object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from AdminLog object
+ }
+
+ if ($criteria->containsKey(AdminLogPeer::ID) && $criteria->keyContainsValue(AdminLogPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminLogPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminLogPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a AdminLog or Criteria object.
+ *
+ * @param mixed $values Criteria or AdminLog object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AdminLogPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AdminLogPeer::ID);
+ $value = $criteria->remove(AdminLogPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AdminLogPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AdminLogPeer::TABLE_NAME);
+ }
+
+ } else { // $values is AdminLog object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AdminLogPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the admin_log table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(AdminLogPeer::TABLE_NAME, $con, AdminLogPeer::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
+ // instances get re-added by the select statement contained therein).
+ AdminLogPeer::clearInstancePool();
+ AdminLogPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AdminLog or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AdminLog object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ AdminLogPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof AdminLog) { // it's a model object
+ // invalidate the cache for this single object
+ AdminLogPeer::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(AdminLogPeer::DATABASE_NAME);
+ $criteria->add(AdminLogPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AdminLogPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminLogPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AdminLogPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given AdminLog object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param AdminLog $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AdminLogPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AdminLogPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AdminLogPeer::DATABASE_NAME, AdminLogPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return AdminLog
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AdminLogPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AdminLogPeer::DATABASE_NAME);
+ $criteria->add(AdminLogPeer::ID, $pk);
+
+ $v = AdminLogPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return AdminLog[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AdminLogPeer::DATABASE_NAME);
+ $criteria->add(AdminLogPeer::ID, $pks, Criteria::IN);
+ $objs = AdminLogPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAdminLogPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAdminLogPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php
new file mode 100644
index 000000000..c36a80193
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php
@@ -0,0 +1,516 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return AdminLog|AdminLog[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AdminLogPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AdminLog A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `ADMIN_LOGIN`, `ADMIN_FIRSTNAME`, `ADMIN_LASTNAME`, `ACTION`, `REQUEST`, `CREATED_AT`, `UPDATED_AT` FROM `admin_log` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new AdminLog();
+ $obj->hydrate($row);
+ AdminLogPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AdminLog|AdminLog[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|AdminLog[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AdminLogPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AdminLogPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AdminLogPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_login column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminLogin('fooValue'); // WHERE admin_login = 'fooValue'
+ * $query->filterByAdminLogin('%fooValue%'); // WHERE admin_login LIKE '%fooValue%'
+ *
+ *
+ * @param string $adminLogin The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByAdminLogin($adminLogin = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($adminLogin)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $adminLogin)) {
+ $adminLogin = str_replace('*', '%', $adminLogin);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogPeer::ADMIN_LOGIN, $adminLogin, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminFirstname('fooValue'); // WHERE admin_firstname = 'fooValue'
+ * $query->filterByAdminFirstname('%fooValue%'); // WHERE admin_firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $adminFirstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByAdminFirstname($adminFirstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($adminFirstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $adminFirstname)) {
+ $adminFirstname = str_replace('*', '%', $adminFirstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogPeer::ADMIN_FIRSTNAME, $adminFirstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminLastname('fooValue'); // WHERE admin_lastname = 'fooValue'
+ * $query->filterByAdminLastname('%fooValue%'); // WHERE admin_lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $adminLastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByAdminLastname($adminLastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($adminLastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $adminLastname)) {
+ $adminLastname = str_replace('*', '%', $adminLastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogPeer::ADMIN_LASTNAME, $adminLastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the action column
+ *
+ * Example usage:
+ *
+ * $query->filterByAction('fooValue'); // WHERE action = 'fooValue'
+ * $query->filterByAction('%fooValue%'); // WHERE action LIKE '%fooValue%'
+ *
+ *
+ * @param string $action The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByAction($action = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($action)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $action)) {
+ $action = str_replace('*', '%', $action);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogPeer::ACTION, $action, $comparison);
+ }
+
+ /**
+ * Filter the query on the request column
+ *
+ * Example usage:
+ *
+ * $query->filterByRequest('fooValue'); // WHERE request = 'fooValue'
+ * $query->filterByRequest('%fooValue%'); // WHERE request LIKE '%fooValue%'
+ *
+ *
+ * @param string $request The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByRequest($request = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($request)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $request)) {
+ $request = str_replace('*', '%', $request);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogPeer::REQUEST, $request, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AdminLogPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AdminLogPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AdminLogPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AdminLogPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param AdminLog $adminLog Object to remove from the list of results
+ *
+ * @return AdminLogQuery The current query, for fluid interface
+ */
+ public function prune($adminLog = null)
+ {
+ if ($adminLog) {
+ $this->addUsingAlias(AdminLogPeer::ID, $adminLog->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAdminPeer.php b/core/lib/Thelia/Model/om/BaseAdminPeer.php
new file mode 100644
index 000000000..e134a3161
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdminPeer.php
@@ -0,0 +1,807 @@
+ array ('Id', 'Firstname', 'Lastname', 'Login', 'Password', 'Algo', 'Salt', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AdminPeer::ID, AdminPeer::FIRSTNAME, AdminPeer::LASTNAME, AdminPeer::LOGIN, AdminPeer::PASSWORD, AdminPeer::ALGO, AdminPeer::SALT, AdminPeer::CREATED_AT, AdminPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRSTNAME', 'LASTNAME', 'LOGIN', 'PASSWORD', 'ALGO', 'SALT', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AdminPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Firstname' => 1, 'Lastname' => 2, 'Login' => 3, 'Password' => 4, 'Algo' => 5, 'Salt' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ BasePeer::TYPE_COLNAME => array (AdminPeer::ID => 0, AdminPeer::FIRSTNAME => 1, AdminPeer::LASTNAME => 2, AdminPeer::LOGIN => 3, AdminPeer::PASSWORD => 4, AdminPeer::ALGO => 5, AdminPeer::SALT => 6, AdminPeer::CREATED_AT => 7, AdminPeer::UPDATED_AT => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRSTNAME' => 1, 'LASTNAME' => 2, 'LOGIN' => 3, 'PASSWORD' => 4, 'ALGO' => 5, 'SALT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AdminPeer::getFieldNames($toType);
+ $key = isset(AdminPeer::$fieldKeys[$fromType][$name]) ? AdminPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AdminPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AdminPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AdminPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AdminPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AdminPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AdminPeer::ID);
+ $criteria->addSelectColumn(AdminPeer::FIRSTNAME);
+ $criteria->addSelectColumn(AdminPeer::LASTNAME);
+ $criteria->addSelectColumn(AdminPeer::LOGIN);
+ $criteria->addSelectColumn(AdminPeer::PASSWORD);
+ $criteria->addSelectColumn(AdminPeer::ALGO);
+ $criteria->addSelectColumn(AdminPeer::SALT);
+ $criteria->addSelectColumn(AdminPeer::CREATED_AT);
+ $criteria->addSelectColumn(AdminPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.LOGIN');
+ $criteria->addSelectColumn($alias . '.PASSWORD');
+ $criteria->addSelectColumn($alias . '.ALGO');
+ $criteria->addSelectColumn($alias . '.SALT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AdminPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Admin
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AdminPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AdminPeer::populateObjects(AdminPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AdminPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Admin $obj A Admin object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AdminPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Admin object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Admin) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Admin object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AdminPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Admin Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AdminPeer::$instances[$key])) {
+ return AdminPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AdminPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to admin
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AdminPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AdminPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AdminPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AdminPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Admin object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AdminPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AdminPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AdminPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AdminPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AdminPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AdminPeer::DATABASE_NAME)->getTable(AdminPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAdminPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAdminPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AdminTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AdminPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Admin or Criteria object.
+ *
+ * @param mixed $values Criteria or Admin object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Admin object
+ }
+
+ if ($criteria->containsKey(AdminPeer::ID) && $criteria->keyContainsValue(AdminPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Admin or Criteria object.
+ *
+ * @param mixed $values Criteria or Admin object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AdminPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AdminPeer::ID);
+ $value = $criteria->remove(AdminPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AdminPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AdminPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Admin object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AdminPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the admin table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(AdminPeer::TABLE_NAME, $con, AdminPeer::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
+ // instances get re-added by the select statement contained therein).
+ AdminPeer::clearInstancePool();
+ AdminPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Admin or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Admin object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ AdminPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Admin) { // it's a model object
+ // invalidate the cache for this single object
+ AdminPeer::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(AdminPeer::DATABASE_NAME);
+ $criteria->add(AdminPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AdminPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AdminPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Admin object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Admin $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AdminPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AdminPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AdminPeer::DATABASE_NAME, AdminPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Admin
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AdminPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AdminPeer::DATABASE_NAME);
+ $criteria->add(AdminPeer::ID, $pk);
+
+ $v = AdminPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Admin[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AdminPeer::DATABASE_NAME);
+ $criteria->add(AdminPeer::ID, $pks, Criteria::IN);
+ $objs = AdminPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAdminPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAdminPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAdminQuery.php b/core/lib/Thelia/Model/om/BaseAdminQuery.php
new file mode 100644
index 000000000..1d895ffcf
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAdminQuery.php
@@ -0,0 +1,630 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Admin|Admin[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AdminPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Admin A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `FIRSTNAME`, `LASTNAME`, `LOGIN`, `PASSWORD`, `ALGO`, `SALT`, `CREATED_AT`, `UPDATED_AT` FROM `admin` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Admin();
+ $obj->hydrate($row);
+ AdminPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Admin|Admin[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Admin[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AdminPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AdminPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AdminPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminPeer::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminPeer::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the login column
+ *
+ * Example usage:
+ *
+ * $query->filterByLogin('fooValue'); // WHERE login = 'fooValue'
+ * $query->filterByLogin('%fooValue%'); // WHERE login LIKE '%fooValue%'
+ *
+ *
+ * @param string $login The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByLogin($login = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($login)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $login)) {
+ $login = str_replace('*', '%', $login);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminPeer::LOGIN, $login, $comparison);
+ }
+
+ /**
+ * Filter the query on the password column
+ *
+ * Example usage:
+ *
+ * $query->filterByPassword('fooValue'); // WHERE password = 'fooValue'
+ * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%'
+ *
+ *
+ * @param string $password The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByPassword($password = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($password)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $password)) {
+ $password = str_replace('*', '%', $password);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminPeer::PASSWORD, $password, $comparison);
+ }
+
+ /**
+ * Filter the query on the algo column
+ *
+ * Example usage:
+ *
+ * $query->filterByAlgo('fooValue'); // WHERE algo = 'fooValue'
+ * $query->filterByAlgo('%fooValue%'); // WHERE algo LIKE '%fooValue%'
+ *
+ *
+ * @param string $algo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByAlgo($algo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($algo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $algo)) {
+ $algo = str_replace('*', '%', $algo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminPeer::ALGO, $algo, $comparison);
+ }
+
+ /**
+ * Filter the query on the salt column
+ *
+ * Example usage:
+ *
+ * $query->filterBySalt('fooValue'); // WHERE salt = 'fooValue'
+ * $query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%'
+ *
+ *
+ * @param string $salt The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterBySalt($salt = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($salt)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $salt)) {
+ $salt = str_replace('*', '%', $salt);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminPeer::SALT, $salt, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AdminPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AdminPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AdminPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AdminPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related AdminGroup object
+ *
+ * @param AdminGroup|PropelObjectCollection $adminGroup the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AdminQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAdminGroup($adminGroup, $comparison = null)
+ {
+ if ($adminGroup instanceof AdminGroup) {
+ return $this
+ ->addUsingAlias(AdminPeer::ID, $adminGroup->getAdminId(), $comparison);
+ } elseif ($adminGroup instanceof PropelObjectCollection) {
+ return $this
+ ->useAdminGroupQuery()
+ ->filterByPrimaryKeys($adminGroup->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AdminGroup relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function joinAdminGroup($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AdminGroup');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AdminGroup');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AdminGroup relation AdminGroup object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query
+ */
+ public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinAdminGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Admin $admin Object to remove from the list of results
+ *
+ * @return AdminQuery The current query, for fluid interface
+ */
+ public function prune($admin = null)
+ {
+ if ($admin) {
+ $this->addUsingAlias(AdminPeer::ID, $admin->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseArea.php b/core/lib/Thelia/Model/om/BaseArea.php
new file mode 100644
index 000000000..15f4ff9df
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseArea.php
@@ -0,0 +1,1616 @@
+id;
+ }
+
+ /**
+ * Get the [name] column value.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get the [unit] column value.
+ *
+ * @return double
+ */
+ public function getUnit()
+ {
+ return $this->unit;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Area The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AreaPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [name] column.
+ *
+ * @param string $v new value
+ * @return Area The current object (for fluent API support)
+ */
+ public function setName($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->name !== $v) {
+ $this->name = $v;
+ $this->modifiedColumns[] = AreaPeer::NAME;
+ }
+
+
+ return $this;
+ } // setName()
+
+ /**
+ * Set the value of [unit] column.
+ *
+ * @param double $v new value
+ * @return Area The current object (for fluent API support)
+ */
+ public function setUnit($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->unit !== $v) {
+ $this->unit = $v;
+ $this->modifiedColumns[] = AreaPeer::UNIT;
+ }
+
+
+ return $this;
+ } // setUnit()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Area The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AreaPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Area The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AreaPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->unit = ($row[$startcol + 2] !== null) ? (double) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = AreaPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Area object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AreaPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collCountrys = null;
+
+ $this->collDelivzones = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AreaQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AreaPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AreaPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AreaPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AreaPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AreaPeer::NAME)) {
+ $modifiedColumns[':p' . $index++] = '`NAME`';
+ }
+ if ($this->isColumnModified(AreaPeer::UNIT)) {
+ $modifiedColumns[':p' . $index++] = '`UNIT`';
+ }
+ if ($this->isColumnModified(AreaPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AreaPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `area` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`NAME`':
+ $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
+ break;
+ case '`UNIT`':
+ $stmt->bindValue($identifier, $this->unit, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AreaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getName();
+ break;
+ case 2:
+ return $this->getUnit();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Area'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Area'][$this->getPrimaryKey()] = true;
+ $keys = AreaPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getName(),
+ $keys[2] => $this->getUnit(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collCountrys) {
+ $result['Countrys'] = $this->collCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDelivzones) {
+ $result['Delivzones'] = $this->collDelivzones->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AreaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setName($value);
+ break;
+ case 2:
+ $this->setUnit($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AreaPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setUnit($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AreaPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AreaPeer::ID)) $criteria->add(AreaPeer::ID, $this->id);
+ if ($this->isColumnModified(AreaPeer::NAME)) $criteria->add(AreaPeer::NAME, $this->name);
+ if ($this->isColumnModified(AreaPeer::UNIT)) $criteria->add(AreaPeer::UNIT, $this->unit);
+ if ($this->isColumnModified(AreaPeer::CREATED_AT)) $criteria->add(AreaPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AreaPeer::UPDATED_AT)) $criteria->add(AreaPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AreaPeer::DATABASE_NAME);
+ $criteria->add(AreaPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Area (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setName($this->getName());
+ $copyObj->setUnit($this->getUnit());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Area Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AreaPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AreaPeer();
+ }
+
+ 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.
+ *
+ * @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 getCountrys($criteria = null, PropelPDO $con = 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 {
+ return count($this->collCountrys);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param Country $country The country object to add.
+ */
+ protected function doAddCountry($country)
+ {
+ $this->collCountrys[]= $country;
+ $country->setArea($this);
+ }
+
+ /**
+ * @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
+ *
+ * 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 getDelivzones($criteria = null, PropelPDO $con = 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 {
+ return count($this->collDelivzones);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * @param Delivzone $delivzone The delivzone object to remove.
+ */
+ public function removeDelivzone($delivzone)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->name = null;
+ $this->unit = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ if ($this->collCountrys instanceof PropelCollection) {
+ $this->collCountrys->clearIterator();
+ }
+ $this->collCountrys = null;
+ if ($this->collDelivzones instanceof PropelCollection) {
+ $this->collDelivzones->clearIterator();
+ }
+ $this->collDelivzones = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AreaPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAreaPeer.php b/core/lib/Thelia/Model/om/BaseAreaPeer.php
new file mode 100644
index 000000000..509b07043
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAreaPeer.php
@@ -0,0 +1,791 @@
+ array ('Id', 'Name', 'Unit', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'unit', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AreaPeer::ID, AreaPeer::NAME, AreaPeer::UNIT, AreaPeer::CREATED_AT, AreaPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'UNIT', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'unit', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AreaPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Unit' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'unit' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (AreaPeer::ID => 0, AreaPeer::NAME => 1, AreaPeer::UNIT => 2, AreaPeer::CREATED_AT => 3, AreaPeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'UNIT' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'unit' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AreaPeer::getFieldNames($toType);
+ $key = isset(AreaPeer::$fieldKeys[$fromType][$name]) ? AreaPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AreaPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AreaPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AreaPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AreaPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AreaPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AreaPeer::ID);
+ $criteria->addSelectColumn(AreaPeer::NAME);
+ $criteria->addSelectColumn(AreaPeer::UNIT);
+ $criteria->addSelectColumn(AreaPeer::CREATED_AT);
+ $criteria->addSelectColumn(AreaPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.NAME');
+ $criteria->addSelectColumn($alias . '.UNIT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AreaPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Area
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AreaPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AreaPeer::populateObjects(AreaPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AreaPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AreaPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Area $obj A Area object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AreaPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Area object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Area) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Area object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AreaPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Area Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AreaPeer::$instances[$key])) {
+ return AreaPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AreaPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to area
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AreaPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AreaPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AreaPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AreaPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Area object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AreaPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AreaPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AreaPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AreaPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AreaPeer::DATABASE_NAME)->getTable(AreaPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAreaPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAreaPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AreaTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AreaPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Area or Criteria object.
+ *
+ * @param mixed $values Criteria or Area object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Area object
+ }
+
+ if ($criteria->containsKey(AreaPeer::ID) && $criteria->keyContainsValue(AreaPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AreaPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AreaPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Area or Criteria object.
+ *
+ * @param mixed $values Criteria or Area object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AreaPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AreaPeer::ID);
+ $value = $criteria->remove(AreaPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AreaPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AreaPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Area object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AreaPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the area table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(AreaPeer::TABLE_NAME, $con, AreaPeer::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
+ // instances get re-added by the select statement contained therein).
+ AreaPeer::clearInstancePool();
+ AreaPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Area or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Area object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ AreaPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Area) { // it's a model object
+ // invalidate the cache for this single object
+ AreaPeer::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(AreaPeer::DATABASE_NAME);
+ $criteria->add(AreaPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AreaPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AreaPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AreaPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Area object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Area $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AreaPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AreaPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AreaPeer::DATABASE_NAME, AreaPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Area
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AreaPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AreaPeer::DATABASE_NAME);
+ $criteria->add(AreaPeer::ID, $pk);
+
+ $v = AreaPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Area[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AreaPeer::DATABASE_NAME);
+ $criteria->add(AreaPeer::ID, $pks, Criteria::IN);
+ $objs = AreaPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAreaPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAreaPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAreaQuery.php b/core/lib/Thelia/Model/om/BaseAreaQuery.php
new file mode 100644
index 000000000..3c25a0bf0
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAreaQuery.php
@@ -0,0 +1,589 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Area|Area[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AreaPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Area A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `NAME`, `UNIT`, `CREATED_AT`, `UPDATED_AT` FROM `area` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Area();
+ $obj->hydrate($row);
+ AreaPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Area|Area[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Area[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AreaPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AreaPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AreaPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the name column
+ *
+ * Example usage:
+ *
+ * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
+ * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
+ *
+ *
+ * @param string $name The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function filterByName($name = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($name)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $name)) {
+ $name = str_replace('*', '%', $name);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AreaPeer::NAME, $name, $comparison);
+ }
+
+ /**
+ * Filter the query on the unit column
+ *
+ * Example usage:
+ *
+ * $query->filterByUnit(1234); // WHERE unit = 1234
+ * $query->filterByUnit(array(12, 34)); // WHERE unit IN (12, 34)
+ * $query->filterByUnit(array('min' => 12)); // WHERE unit > 12
+ *
+ *
+ * @param mixed $unit The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function filterByUnit($unit = null, $comparison = null)
+ {
+ if (is_array($unit)) {
+ $useMinMax = false;
+ if (isset($unit['min'])) {
+ $this->addUsingAlias(AreaPeer::UNIT, $unit['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($unit['max'])) {
+ $this->addUsingAlias(AreaPeer::UNIT, $unit['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AreaPeer::UNIT, $unit, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AreaPeer::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 AreaQuery 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(AreaPeer::ID, $country->getAreaId(), $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 AreaQuery 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');
+ }
+
+ /**
+ * Filter the query by a related Delivzone object
+ *
+ * @param Delivzone|PropelObjectCollection $delivzone the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AreaQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByDelivzone($delivzone, $comparison = null)
+ {
+ if ($delivzone instanceof Delivzone) {
+ return $this
+ ->addUsingAlias(AreaPeer::ID, $delivzone->getAreaId(), $comparison);
+ } elseif ($delivzone instanceof PropelObjectCollection) {
+ return $this
+ ->useDelivzoneQuery()
+ ->filterByPrimaryKeys($delivzone->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDelivzone() only accepts arguments of type Delivzone or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Delivzone relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Delivzone');
+
+ // 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, 'Delivzone');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Delivzone relation Delivzone 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\DelivzoneQuery A secondary query class using the current class as primary query
+ */
+ public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDelivzone($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Delivzone', '\Thelia\Model\DelivzoneQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Area $area Object to remove from the list of results
+ *
+ * @return AreaQuery The current query, for fluid interface
+ */
+ public function prune($area = null)
+ {
+ if ($area) {
+ $this->addUsingAlias(AreaPeer::ID, $area->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttribute.php b/core/lib/Thelia/Model/om/BaseAttribute.php
new file mode 100644
index 000000000..e695341dc
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttribute.php
@@ -0,0 +1,2172 @@
+id;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Attribute The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Attribute The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = AttributePeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Attribute The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Attribute The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->position = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = AttributePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Attribute object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AttributePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAttributeAvs = null;
+
+ $this->collAttributeCategorys = null;
+
+ $this->collAttributeCombinations = null;
+
+ $this->collAttributeDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AttributeQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AttributePeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(AttributePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AttributePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `attribute` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getPosition();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Attribute'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Attribute'][$this->getPrimaryKey()] = true;
+ $keys = AttributePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getPosition(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collAttributeAvs) {
+ $result['AttributeAvs'] = $this->collAttributeAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeCategorys) {
+ $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeDescs) {
+ $result['AttributeDescs'] = $this->collAttributeDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setPosition($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AttributePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setPosition($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AttributePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributePeer::ID)) $criteria->add(AttributePeer::ID, $this->id);
+ if ($this->isColumnModified(AttributePeer::POSITION)) $criteria->add(AttributePeer::POSITION, $this->position);
+ if ($this->isColumnModified(AttributePeer::CREATED_AT)) $criteria->add(AttributePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributePeer::UPDATED_AT)) $criteria->add(AttributePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AttributePeer::DATABASE_NAME);
+ $criteria->add(AttributePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Attribute (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ foreach ($this->getAttributeCategorys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAttributeCombinations() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCombination($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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Attribute Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AttributePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AttributePeer();
+ }
+
+ 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.
+ *
+ * @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 getAttributeAvs($criteria = null, PropelPDO $con = 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 {
+ return count($this->collAttributeAvs);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param AttributeAv $attributeAv The attributeAv object to add.
+ */
+ protected function doAddAttributeAv($attributeAv)
+ {
+ $this->collAttributeAvs[]= $attributeAv;
+ $attributeAv->setAttribute($this);
+ }
+
+ /**
+ * @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
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeCategorys()
+ */
+ public function clearAttributeCategorys()
+ {
+ $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized
+ $this->collAttributeCategorysPartial = null;
+ }
+
+ /**
+ * reset is the collAttributeCategorys collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialAttributeCategorys($v = true)
+ {
+ $this->collAttributeCategorysPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCategorys collection.
+ *
+ * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeCategorys($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCategorys && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCategorys = new PropelObjectCollection();
+ $this->collAttributeCategorys->setModel('AttributeCategory');
+ }
+
+ /**
+ * Gets an array of AttributeCategory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this Attribute is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects
+ * @throws PropelException
+ */
+ public function getAttributeCategorys($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeCategorysPartial && !$this->isNew();
+ if (null === $this->collAttributeCategorys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCategorys) {
+ // return empty collection
+ $this->initAttributeCategorys();
+ } else {
+ $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) {
+ $this->initAttributeCategorys(false);
+
+ foreach($collAttributeCategorys as $obj) {
+ if (false == $this->collAttributeCategorys->contains($obj)) {
+ $this->collAttributeCategorys->append($obj);
+ }
+ }
+
+ $this->collAttributeCategorysPartial = true;
+ }
+
+ return $collAttributeCategorys;
+ }
+
+ if($partial && $this->collAttributeCategorys) {
+ foreach($this->collAttributeCategorys as $obj) {
+ if($obj->isNew()) {
+ $collAttributeCategorys[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCategorys = $collAttributeCategorys;
+ $this->collAttributeCategorysPartial = false;
+ }
+ }
+
+ return $this->collAttributeCategorys;
+ }
+
+ /**
+ * Sets a collection of AttributeCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $attributeCategorys A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null)
+ {
+ $this->attributeCategorysScheduledForDeletion = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys);
+
+ foreach ($this->attributeCategorysScheduledForDeletion as $attributeCategoryRemoved) {
+ $attributeCategoryRemoved->setAttribute(null);
+ }
+
+ $this->collAttributeCategorys = null;
+ foreach ($attributeCategorys as $attributeCategory) {
+ $this->addAttributeCategory($attributeCategory);
+ }
+
+ $this->collAttributeCategorys = $attributeCategorys;
+ $this->collAttributeCategorysPartial = false;
+ }
+
+ /**
+ * Returns the number of related AttributeCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AttributeCategory objects.
+ * @throws PropelException
+ */
+ public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeCategorysPartial && !$this->isNew();
+ if (null === $this->collAttributeCategorys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCategorys) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAttributeCategorys());
+ }
+ $query = AttributeCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAttributeCategorys);
+ }
+ }
+
+ /**
+ * Method called to associate a AttributeCategory object to this object
+ * through the AttributeCategory foreign key attribute.
+ *
+ * @param AttributeCategory $l AttributeCategory
+ * @return Attribute The current object (for fluent API support)
+ */
+ public function addAttributeCategory(AttributeCategory $l)
+ {
+ if ($this->collAttributeCategorys === null) {
+ $this->initAttributeCategorys();
+ $this->collAttributeCategorysPartial = true;
+ }
+ if (!$this->collAttributeCategorys->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeCategory $attributeCategory The attributeCategory object to add.
+ */
+ protected function doAddAttributeCategory($attributeCategory)
+ {
+ $this->collAttributeCategorys[]= $attributeCategory;
+ $attributeCategory->setAttribute($this);
+ }
+
+ /**
+ * @param AttributeCategory $attributeCategory The attributeCategory object to remove.
+ */
+ public function removeAttributeCategory($attributeCategory)
+ {
+ if ($this->getAttributeCategorys()->contains($attributeCategory)) {
+ $this->collAttributeCategorys->remove($this->collAttributeCategorys->search($attributeCategory));
+ if (null === $this->attributeCategorysScheduledForDeletion) {
+ $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys;
+ $this->attributeCategorysScheduledForDeletion->clear();
+ }
+ $this->attributeCategorysScheduledForDeletion[]= $attributeCategory;
+ $attributeCategory->setAttribute(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Attribute is new, it will return
+ * an empty collection; or if this Attribute has previously
+ * been saved, it will retrieve related AttributeCategorys from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Attribute.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects
+ */
+ public function getAttributeCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = AttributeCategoryQuery::create(null, $criteria);
+ $query->joinWith('Category', $join_behavior);
+
+ return $this->getAttributeCategorys($query, $con);
+ }
+
+ /**
+ * Clears out the collAttributeCombinations collection
+ *
+ * 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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to add.
+ */
+ protected function doAddAttributeCombination($attributeCombination)
+ {
+ $this->collAttributeCombinations[]= $attributeCombination;
+ $attributeCombination->setAttribute($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->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.
+ *
+ * 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 getAttributeDescs($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeDescsPartial && !$this->isNew();
+ if (null === $this->collAttributeDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeDescs) {
+ // return empty collection
+ $this->initAttributeDescs();
+ } else {
+ $collAttributeDescs = AttributeDescQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeDescsPartial && count($collAttributeDescs)) {
+ $this->initAttributeDescs(false);
+
+ foreach($collAttributeDescs as $obj) {
+ if (false == $this->collAttributeDescs->contains($obj)) {
+ $this->collAttributeDescs->append($obj);
+ }
+ }
+
+ $this->collAttributeDescsPartial = true;
+ }
+
+ return $collAttributeDescs;
+ }
+
+ if($partial && $this->collAttributeDescs) {
+ foreach($this->collAttributeDescs as $obj) {
+ if($obj->isNew()) {
+ $collAttributeDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeDescs = $collAttributeDescs;
+ $this->collAttributeDescsPartial = false;
+ }
+ }
+
+ return $this->collAttributeDescs;
+ }
+
+ /**
+ * Sets a collection of AttributeDesc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $attributeDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setAttributeDescs(PropelCollection $attributeDescs, PropelPDO $con = null)
+ {
+ $this->attributeDescsScheduledForDeletion = $this->getAttributeDescs(new Criteria(), $con)->diff($attributeDescs);
+
+ foreach ($this->attributeDescsScheduledForDeletion as $attributeDescRemoved) {
+ $attributeDescRemoved->setAttribute(null);
+ }
+
+ $this->collAttributeDescs = null;
+ foreach ($attributeDescs as $attributeDesc) {
+ $this->addAttributeDesc($attributeDesc);
+ }
+
+ $this->collAttributeDescs = $attributeDescs;
+ $this->collAttributeDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related AttributeDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related AttributeDesc objects.
+ * @throws PropelException
+ */
+ public function countAttributeDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeDescsPartial && !$this->isNew();
+ if (null === $this->collAttributeDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getAttributeDescs());
+ }
+ $query = AttributeDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAttributeDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a AttributeDesc object to this object
+ * through the AttributeDesc foreign key attribute.
+ *
+ * @param AttributeDesc $l AttributeDesc
+ * @return Attribute The current object (for fluent API support)
+ */
+ public function addAttributeDesc(AttributeDesc $l)
+ {
+ if ($this->collAttributeDescs === null) {
+ $this->initAttributeDescs();
+ $this->collAttributeDescsPartial = true;
+ }
+ if (!$this->collAttributeDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeDesc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeDesc $attributeDesc The attributeDesc object to add.
+ */
+ protected function doAddAttributeDesc($attributeDesc)
+ {
+ $this->collAttributeDescs[]= $attributeDesc;
+ $attributeDesc->setAttribute($this);
+ }
+
+ /**
+ * @param AttributeDesc $attributeDesc The attributeDesc object to remove.
+ */
+ public function removeAttributeDesc($attributeDesc)
+ {
+ if ($this->getAttributeDescs()->contains($attributeDesc)) {
+ $this->collAttributeDescs->remove($this->collAttributeDescs->search($attributeDesc));
+ if (null === $this->attributeDescsScheduledForDeletion) {
+ $this->attributeDescsScheduledForDeletion = clone $this->collAttributeDescs;
+ $this->attributeDescsScheduledForDeletion->clear();
+ }
+ $this->attributeDescsScheduledForDeletion[]= $attributeDesc;
+ $attributeDesc->setAttribute(null);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ 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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAv.php b/core/lib/Thelia/Model/om/BaseAttributeAv.php
new file mode 100644
index 000000000..b99f10b08
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeAv.php
@@ -0,0 +1,1758 @@
+id;
+ }
+
+ /**
+ * Get the [attribute_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeId()
+ {
+ return $this->attribute_id;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return AttributeAv The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeAvPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [attribute_id] column.
+ *
+ * @param int $v new value
+ * @return AttributeAv The current object (for fluent API support)
+ */
+ public function setAttributeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_id !== $v) {
+ $this->attribute_id = $v;
+ $this->modifiedColumns[] = AttributeAvPeer::ATTRIBUTE_ID;
+ }
+
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
+
+ return $this;
+ } // setAttributeId()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return AttributeAv The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = AttributeAvPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeAv The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeAvPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeAv The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeAvPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->attribute_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = AttributeAvPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating AttributeAv object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AttributeAvPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aAttribute = null;
+ $this->collAttributeAvDescs = null;
+
+ $this->collAttributeCombinations = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AttributeAvQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeAvPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->attributeAvDescsScheduledForDeletion !== null) {
+ if (!$this->attributeAvDescsScheduledForDeletion->isEmpty()) {
+ AttributeAvDescQuery::create()
+ ->filterByPrimaryKeys($this->attributeAvDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeAvDescsScheduledForDeletion = null;
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeAvPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeAvPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeAvPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AttributeAvPeer::ATTRIBUTE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_ID`';
+ }
+ if ($this->isColumnModified(AttributeAvPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(AttributeAvPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AttributeAvPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `attribute_av` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`ATTRIBUTE_ID`':
+ $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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 = AttributeAvPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ 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());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getAttributeId();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeAv'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeAv'][$this->getPrimaryKey()] = true;
+ $keys = AttributeAvPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAttributeId(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collAttributeAvDescs) {
+ $result['AttributeAvDescs'] = $this->collAttributeAvDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setAttributeId($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AttributeAvPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeAvPeer::ID)) $criteria->add(AttributeAvPeer::ID, $this->id);
+ if ($this->isColumnModified(AttributeAvPeer::ATTRIBUTE_ID)) $criteria->add(AttributeAvPeer::ATTRIBUTE_ID, $this->attribute_id);
+ if ($this->isColumnModified(AttributeAvPeer::POSITION)) $criteria->add(AttributeAvPeer::POSITION, $this->position);
+ if ($this->isColumnModified(AttributeAvPeer::CREATED_AT)) $criteria->add(AttributeAvPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeAvPeer::UPDATED_AT)) $criteria->add(AttributeAvPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME);
+ $criteria->add(AttributeAvPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of AttributeAv (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAttributeId($this->getAttributeId());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return AttributeAv Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AttributeAvPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AttributeAvPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Attribute object.
+ *
+ * @param Attribute $v
+ * @return AttributeAv 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->addAttributeAv($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->addAttributeAvs($this);
+ */
+ }
+
+ return $this->aAttribute;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AttributeAvDesc' == $relationName) {
+ $this->initAttributeAvDescs();
+ }
+ if ('AttributeCombination' == $relationName) {
+ $this->initAttributeCombinations();
+ }
+ }
+
+ /**
+ * 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 PropelObjectCollection|AttributeAvDesc[] List of AttributeAvDesc objects
+ * @throws PropelException
+ */
+ 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);
+
+ 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->collAttributeAvDescs;
+ }
+
+ /**
+ * 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 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 countAttributeAvDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $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();
+ }
+
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->attribute_id = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($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->collAttributeAvDescs instanceof PropelCollection) {
+ $this->collAttributeAvDescs->clearIterator();
+ }
+ $this->collAttributeAvDescs = null;
+ if ($this->collAttributeCombinations instanceof PropelCollection) {
+ $this->collAttributeCombinations->clearIterator();
+ }
+ $this->collAttributeCombinations = null;
+ $this->aAttribute = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeAvPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php b/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php
new file mode 100644
index 000000000..32ecd67f7
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php
@@ -0,0 +1,1320 @@
+id;
+ }
+
+ /**
+ * Get the [attribute_av_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeAvId()
+ {
+ return $this->attribute_av_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return AttributeAvDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeAvDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [attribute_av_id] column.
+ *
+ * @param int $v new value
+ * @return AttributeAvDesc The current object (for fluent API support)
+ */
+ public function setAttributeAvId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_av_id !== $v) {
+ $this->attribute_av_id = $v;
+ $this->modifiedColumns[] = AttributeAvDescPeer::ATTRIBUTE_AV_ID;
+ }
+
+ if ($this->aAttributeAv !== null && $this->aAttributeAv->getId() !== $v) {
+ $this->aAttributeAv = null;
+ }
+
+
+ return $this;
+ } // setAttributeAvId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return AttributeAvDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = AttributeAvDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return AttributeAvDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = AttributeAvDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return AttributeAvDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = AttributeAvDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return AttributeAvDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = AttributeAvDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeAvDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeAvDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeAvDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeAvDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->attribute_av_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = AttributeAvDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating AttributeAvDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) {
+ $this->aAttributeAv = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AttributeAvDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aAttributeAv = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AttributeAvDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeAvDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeAvDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeAvDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeAvDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AttributeAvDescPeer::ATTRIBUTE_AV_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_AV_ID`';
+ }
+ if ($this->isColumnModified(AttributeAvDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(AttributeAvDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(AttributeAvDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(AttributeAvDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(AttributeAvDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AttributeAvDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `attribute_av_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`ATTRIBUTE_AV_ID`':
+ $stmt->bindValue($identifier, $this->attribute_av_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeAvDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getAttributeAvId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeAvDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeAvDesc'][$this->getPrimaryKey()] = true;
+ $keys = AttributeAvDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAttributeAvId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aAttributeAv) {
+ $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeAvDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setAttributeAvId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AttributeAvDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAttributeAvId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AttributeAvDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeAvDescPeer::ID)) $criteria->add(AttributeAvDescPeer::ID, $this->id);
+ if ($this->isColumnModified(AttributeAvDescPeer::ATTRIBUTE_AV_ID)) $criteria->add(AttributeAvDescPeer::ATTRIBUTE_AV_ID, $this->attribute_av_id);
+ if ($this->isColumnModified(AttributeAvDescPeer::LANG)) $criteria->add(AttributeAvDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(AttributeAvDescPeer::TITLE)) $criteria->add(AttributeAvDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(AttributeAvDescPeer::DESCRIPTION)) $criteria->add(AttributeAvDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(AttributeAvDescPeer::CHAPO)) $criteria->add(AttributeAvDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(AttributeAvDescPeer::CREATED_AT)) $criteria->add(AttributeAvDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeAvDescPeer::UPDATED_AT)) $criteria->add(AttributeAvDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AttributeAvDescPeer::DATABASE_NAME);
+ $criteria->add(AttributeAvDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of AttributeAvDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAttributeAvId($this->getAttributeAvId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return AttributeAvDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AttributeAvDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AttributeAvDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a AttributeAv object.
+ *
+ * @param AttributeAv $v
+ * @return AttributeAvDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttributeAv(AttributeAv $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->attribute_av_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aAttributeAv = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeAvDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvDescPeer.php b/core/lib/Thelia/Model/om/BaseAttributeAvDescPeer.php
new file mode 100644
index 000000000..35a5dd8e2
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvDescPeer.php
@@ -0,0 +1,1037 @@
+ array ('Id', 'AttributeAvId', 'Lang', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'attributeAvId', 'lang', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AttributeAvDescPeer::ID, AttributeAvDescPeer::ATTRIBUTE_AV_ID, AttributeAvDescPeer::LANG, AttributeAvDescPeer::TITLE, AttributeAvDescPeer::DESCRIPTION, AttributeAvDescPeer::CHAPO, AttributeAvDescPeer::CREATED_AT, AttributeAvDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ATTRIBUTE_AV_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'attribute_av_id', 'lang', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AttributeAvDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AttributeAvId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'attributeAvId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (AttributeAvDescPeer::ID => 0, AttributeAvDescPeer::ATTRIBUTE_AV_ID => 1, AttributeAvDescPeer::LANG => 2, AttributeAvDescPeer::TITLE => 3, AttributeAvDescPeer::DESCRIPTION => 4, AttributeAvDescPeer::CHAPO => 5, AttributeAvDescPeer::CREATED_AT => 6, AttributeAvDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ATTRIBUTE_AV_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'attribute_av_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AttributeAvDescPeer::getFieldNames($toType);
+ $key = isset(AttributeAvDescPeer::$fieldKeys[$fromType][$name]) ? AttributeAvDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributeAvDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AttributeAvDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AttributeAvDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AttributeAvDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AttributeAvDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeAvDescPeer::ID);
+ $criteria->addSelectColumn(AttributeAvDescPeer::ATTRIBUTE_AV_ID);
+ $criteria->addSelectColumn(AttributeAvDescPeer::LANG);
+ $criteria->addSelectColumn(AttributeAvDescPeer::TITLE);
+ $criteria->addSelectColumn(AttributeAvDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(AttributeAvDescPeer::CHAPO);
+ $criteria->addSelectColumn(AttributeAvDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(AttributeAvDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return AttributeAvDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AttributeAvDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AttributeAvDescPeer::populateObjects(AttributeAvDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AttributeAvDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param AttributeAvDesc $obj A AttributeAvDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AttributeAvDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A AttributeAvDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof AttributeAvDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AttributeAvDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AttributeAvDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return AttributeAvDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AttributeAvDescPeer::$instances[$key])) {
+ return AttributeAvDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AttributeAvDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to attribute_av_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AttributeAvDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AttributeAvDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AttributeAvDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeAvDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeAvDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AttributeAvDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AttributeAvDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AttributeAvDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeAvDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AttributeAvDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AttributeAvDescPeer::DATABASE_NAME)->getTable(AttributeAvDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAttributeAvDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAttributeAvDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeAvDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AttributeAvDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeAvDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeAvDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from AttributeAvDesc object
+ }
+
+ if ($criteria->containsKey(AttributeAvDescPeer::ID) && $criteria->keyContainsValue(AttributeAvDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeAvDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a AttributeAvDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeAvDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AttributeAvDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AttributeAvDescPeer::ID);
+ $value = $criteria->remove(AttributeAvDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AttributeAvDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributeAvDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is AttributeAvDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_av_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ AttributeAvDescPeer::clearInstancePool();
+ AttributeAvDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeAvDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeAvDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(AttributeAvDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AttributeAvDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given AttributeAvDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param AttributeAvDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AttributeAvDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AttributeAvDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AttributeAvDescPeer::DATABASE_NAME, AttributeAvDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return AttributeAvDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AttributeAvDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AttributeAvDescPeer::DATABASE_NAME);
+ $criteria->add(AttributeAvDescPeer::ID, $pk);
+
+ $v = AttributeAvDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return AttributeAvDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AttributeAvDescPeer::DATABASE_NAME);
+ $criteria->add(AttributeAvDescPeer::ID, $pks, Criteria::IN);
+ $objs = AttributeAvDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAttributeAvDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAttributeAvDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php
new file mode 100644
index 000000000..09be2e38f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php
@@ -0,0 +1,613 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return AttributeAvDesc|AttributeAvDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeAvDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeAvDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `ATTRIBUTE_AV_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `attribute_av_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new AttributeAvDesc();
+ $obj->hydrate($row);
+ AttributeAvDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeAvDesc|AttributeAvDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|AttributeAvDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AttributeAvDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AttributeAvDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributeAvDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_av_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeAvId(1234); // WHERE attribute_av_id = 1234
+ * $query->filterByAttributeAvId(array(12, 34)); // WHERE attribute_av_id IN (12, 34)
+ * $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id > 12
+ *
+ *
+ * @see filterByAttributeAv()
+ *
+ * @param mixed $attributeAvId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByAttributeAvId($attributeAvId = null, $comparison = null)
+ {
+ if (is_array($attributeAvId)) {
+ $useMinMax = false;
+ if (isset($attributeAvId['min'])) {
+ $this->addUsingAlias(AttributeAvDescPeer::ATTRIBUTE_AV_ID, $attributeAvId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($attributeAvId['max'])) {
+ $this->addUsingAlias(AttributeAvDescPeer::ATTRIBUTE_AV_ID, $attributeAvId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvDescPeer::ATTRIBUTE_AV_ID, $attributeAvId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeAvDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeAvDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeAvDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeAvDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related AttributeAv object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeAv($attributeAv, $comparison = null)
+ {
+ if ($attributeAv instanceof AttributeAv) {
+ return $this
+ ->addUsingAlias(AttributeAvDescPeer::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison);
+ } elseif ($attributeAv instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeAvDescPeer::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeAv');
+
+ // 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, 'AttributeAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeAv relation AttributeAv 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\AttributeAvQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param AttributeAvDesc $attributeAvDesc Object to remove from the list of results
+ *
+ * @return AttributeAvDescQuery The current query, for fluid interface
+ */
+ public function prune($attributeAvDesc = null)
+ {
+ if ($attributeAvDesc) {
+ $this->addUsingAlias(AttributeAvDescPeer::ID, $attributeAvDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php b/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php
new file mode 100644
index 000000000..188d12186
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php
@@ -0,0 +1,1030 @@
+ array ('Id', 'AttributeId', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'attributeId', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AttributeAvPeer::ID, AttributeAvPeer::ATTRIBUTE_ID, AttributeAvPeer::POSITION, AttributeAvPeer::CREATED_AT, AttributeAvPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ATTRIBUTE_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'attribute_id', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AttributeAvPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AttributeId' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'attributeId' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (AttributeAvPeer::ID => 0, AttributeAvPeer::ATTRIBUTE_ID => 1, AttributeAvPeer::POSITION => 2, AttributeAvPeer::CREATED_AT => 3, AttributeAvPeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ATTRIBUTE_ID' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'attribute_id' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AttributeAvPeer::getFieldNames($toType);
+ $key = isset(AttributeAvPeer::$fieldKeys[$fromType][$name]) ? AttributeAvPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributeAvPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AttributeAvPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AttributeAvPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AttributeAvPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AttributeAvPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeAvPeer::ID);
+ $criteria->addSelectColumn(AttributeAvPeer::ATTRIBUTE_ID);
+ $criteria->addSelectColumn(AttributeAvPeer::POSITION);
+ $criteria->addSelectColumn(AttributeAvPeer::CREATED_AT);
+ $criteria->addSelectColumn(AttributeAvPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return AttributeAv
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AttributeAvPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AttributeAvPeer::populateObjects(AttributeAvPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AttributeAvPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param AttributeAv $obj A AttributeAv object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AttributeAvPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A AttributeAv object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof AttributeAv) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AttributeAv object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AttributeAvPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return AttributeAv Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AttributeAvPeer::$instances[$key])) {
+ return AttributeAvPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AttributeAvPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to attribute_av
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in AttributeAvDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AttributeAvPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AttributeAvPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AttributeAvPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeAvPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeAv object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AttributeAvPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AttributeAvPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeAvPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AttributeAvPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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(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::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 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
+ * @return array Array of AttributeAv 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(AttributeAvPeer::DATABASE_NAME);
+ }
+
+ AttributeAvPeer::addSelectColumns($criteria);
+ $startcol = AttributeAvPeer::NUM_HYDRATE_COLUMNS;
+ AttributePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::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 = 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 (AttributeAv) to $obj2 (Attribute)
+ $obj2->addAttributeAv($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(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::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 AttributeAv 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 AttributeAv 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(AttributeAvPeer::DATABASE_NAME);
+ }
+
+ AttributeAvPeer::addSelectColumns($criteria);
+ $startcol2 = AttributeAvPeer::NUM_HYDRATE_COLUMNS;
+
+ AttributePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::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 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 (AttributeAv) to the collection in $obj2 (Attribute)
+ $obj2->addAttributeAv($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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AttributeAvPeer::DATABASE_NAME)->getTable(AttributeAvPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAttributeAvPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAttributeAvPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeAvTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AttributeAvPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeAv or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeAv object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from AttributeAv object
+ }
+
+ if ($criteria->containsKey(AttributeAvPeer::ID) && $criteria->keyContainsValue(AttributeAvPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeAvPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a AttributeAv or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeAv object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AttributeAvPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AttributeAvPeer::ID);
+ $value = $criteria->remove(AttributeAvPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AttributeAvPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributeAvPeer::TABLE_NAME);
+ }
+
+ } else { // $values is AttributeAv object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_av table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ AttributeAvPeer::clearInstancePool();
+ AttributeAvPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeAv or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeAv object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(AttributeAvPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AttributeAvPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given AttributeAv object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param AttributeAv $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AttributeAvPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AttributeAvPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AttributeAvPeer::DATABASE_NAME, AttributeAvPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return AttributeAv
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AttributeAvPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME);
+ $criteria->add(AttributeAvPeer::ID, $pk);
+
+ $v = AttributeAvPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return AttributeAv[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME);
+ $criteria->add(AttributeAvPeer::ID, $pks, Criteria::IN);
+ $objs = AttributeAvPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAttributeAvPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAttributeAvPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php
new file mode 100644
index 000000000..ee2538c78
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php
@@ -0,0 +1,684 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return AttributeAv|AttributeAv[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeAvPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeAv A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `ATTRIBUTE_ID`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `attribute_av` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new AttributeAv();
+ $obj->hydrate($row);
+ AttributeAvPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeAv|AttributeAv[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|AttributeAv[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AttributeAvPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AttributeAvPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributeAvPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
+ * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
+ * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
+ *
+ *
+ * @see filterByAttribute()
+ *
+ * @param mixed $attributeId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByAttributeId($attributeId = null, $comparison = null)
+ {
+ if (is_array($attributeId)) {
+ $useMinMax = false;
+ if (isset($attributeId['min'])) {
+ $this->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($attributeId['max'])) {
+ $this->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attributeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(AttributeAvPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(AttributeAvPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeAvPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeAvPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ 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 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 filterByAttributeAvDesc($attributeAvDesc, $comparison = null)
+ {
+ if ($attributeAvDesc instanceof AttributeAvDesc) {
+ return $this
+ ->addUsingAlias(AttributeAvPeer::ID, $attributeAvDesc->getAttributeAvId(), $comparison);
+ } elseif ($attributeAvDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useAttributeAvDescQuery()
+ ->filterByPrimaryKeys($attributeAvDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeAvDesc() only accepts arguments of type AttributeAvDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeAvDesc 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 joinAttributeAvDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeAvDesc');
+
+ // 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, 'AttributeAvDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeAvDesc relation AttributeAvDesc 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\AttributeAvDescQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeAvDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeAvDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAvDesc', '\Thelia\Model\AttributeAvDescQuery');
+ }
+
+ /**
+ * Filter the query by a related AttributeCombination object
+ *
+ * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeCombination($attributeCombination, $comparison = null)
+ {
+ if ($attributeCombination instanceof AttributeCombination) {
+ return $this
+ ->addUsingAlias(AttributeAvPeer::ID, $attributeCombination->getAttributeAvId(), $comparison);
+ } elseif ($attributeCombination instanceof PropelObjectCollection) {
+ return $this
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCombination 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 joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCombination');
+
+ // 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, 'AttributeCombination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCombination relation AttributeCombination 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\AttributeCombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param AttributeAv $attributeAv Object to remove from the list of results
+ *
+ * @return AttributeAvQuery The current query, for fluid interface
+ */
+ public function prune($attributeAv = null)
+ {
+ if ($attributeAv) {
+ $this->addUsingAlias(AttributeAvPeer::ID, $attributeAv->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategory.php b/core/lib/Thelia/Model/om/BaseAttributeCategory.php
new file mode 100644
index 000000000..83289bb94
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeCategory.php
@@ -0,0 +1,1238 @@
+id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [attribute_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeId()
+ {
+ return $this->attribute_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return AttributeCategory The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeCategoryPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return AttributeCategory The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = AttributeCategoryPeer::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [attribute_id] column.
+ *
+ * @param int $v new value
+ * @return AttributeCategory The current object (for fluent API support)
+ */
+ public function setAttributeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_id !== $v) {
+ $this->attribute_id = $v;
+ $this->modifiedColumns[] = AttributeCategoryPeer::ATTRIBUTE_ID;
+ }
+
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
+
+ return $this;
+ } // setAttributeId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeCategory The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeCategoryPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeCategory The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeCategoryPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->category_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->attribute_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating AttributeCategory object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AttributeCategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ $this->aAttribute = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AttributeCategoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeCategoryPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeCategoryPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCategoryPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeCategoryPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AttributeCategoryPeer::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`';
+ }
+ if ($this->isColumnModified(AttributeCategoryPeer::ATTRIBUTE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_ID`';
+ }
+ if ($this->isColumnModified(AttributeCategoryPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `attribute_category` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CATEGORY_ID`':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case '`ATTRIBUTE_ID`':
+ $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCategoryId();
+ break;
+ case 2:
+ return $this->getAttributeId();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()] = true;
+ $keys = AttributeCategoryPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCategoryId(),
+ $keys[2] => $this->getAttributeId(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCategoryId($value);
+ break;
+ case 2:
+ $this->setAttributeId($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AttributeCategoryPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAttributeId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeCategoryPeer::ID)) $criteria->add(AttributeCategoryPeer::ID, $this->id);
+ if ($this->isColumnModified(AttributeCategoryPeer::CATEGORY_ID)) $criteria->add(AttributeCategoryPeer::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(AttributeCategoryPeer::ATTRIBUTE_ID)) $criteria->add(AttributeCategoryPeer::ATTRIBUTE_ID, $this->attribute_id);
+ if ($this->isColumnModified(AttributeCategoryPeer::CREATED_AT)) $criteria->add(AttributeCategoryPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) $criteria->add(AttributeCategoryPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME);
+ $criteria->add(AttributeCategoryPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of AttributeCategory (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setAttributeId($this->getAttributeId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return AttributeCategory Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AttributeCategoryPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AttributeCategoryPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return AttributeCategory 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->category_id = null;
+ $this->attribute_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ $this->aAttribute = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeCategoryPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php
new file mode 100644
index 000000000..35b5cb7b1
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php
@@ -0,0 +1,1416 @@
+ array ('Id', 'CategoryId', 'AttributeId', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'categoryId', 'attributeId', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AttributeCategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, AttributeCategoryPeer::ATTRIBUTE_ID, AttributeCategoryPeer::CREATED_AT, AttributeCategoryPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CATEGORY_ID', 'ATTRIBUTE_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'category_id', 'attribute_id', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AttributeCategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CategoryId' => 1, 'AttributeId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'categoryId' => 1, 'attributeId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (AttributeCategoryPeer::ID => 0, AttributeCategoryPeer::CATEGORY_ID => 1, AttributeCategoryPeer::ATTRIBUTE_ID => 2, AttributeCategoryPeer::CREATED_AT => 3, AttributeCategoryPeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CATEGORY_ID' => 1, 'ATTRIBUTE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'category_id' => 1, 'attribute_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AttributeCategoryPeer::getFieldNames($toType);
+ $key = isset(AttributeCategoryPeer::$fieldKeys[$fromType][$name]) ? AttributeCategoryPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributeCategoryPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AttributeCategoryPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AttributeCategoryPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AttributeCategoryPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AttributeCategoryPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeCategoryPeer::ID);
+ $criteria->addSelectColumn(AttributeCategoryPeer::CATEGORY_ID);
+ $criteria->addSelectColumn(AttributeCategoryPeer::ATTRIBUTE_ID);
+ $criteria->addSelectColumn(AttributeCategoryPeer::CREATED_AT);
+ $criteria->addSelectColumn(AttributeCategoryPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return AttributeCategory
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AttributeCategoryPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AttributeCategoryPeer::populateObjects(AttributeCategoryPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AttributeCategoryPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param AttributeCategory $obj A AttributeCategory object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AttributeCategoryPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A AttributeCategory object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof AttributeCategory) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AttributeCategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AttributeCategoryPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return AttributeCategory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AttributeCategoryPeer::$instances[$key])) {
+ return AttributeCategoryPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AttributeCategoryPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to attribute_category
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AttributeCategoryPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AttributeCategoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeCategoryPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeCategory object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AttributeCategoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeCategoryPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AttributeCategoryPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AttributeCategoryPeer::DATABASE_NAME)->getTable(AttributeCategoryPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAttributeCategoryPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAttributeCategoryPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeCategoryTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AttributeCategoryPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeCategory or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeCategory object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from AttributeCategory object
+ }
+
+ if ($criteria->containsKey(AttributeCategoryPeer::ID) && $criteria->keyContainsValue(AttributeCategoryPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCategoryPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a AttributeCategory or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeCategory object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AttributeCategoryPeer::ID);
+ $value = $criteria->remove(AttributeCategoryPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AttributeCategoryPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME);
+ }
+
+ } else { // $values is AttributeCategory object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_category table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ AttributeCategoryPeer::clearInstancePool();
+ AttributeCategoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AttributeCategoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given AttributeCategory object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param AttributeCategory $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AttributeCategoryPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AttributeCategoryPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AttributeCategoryPeer::DATABASE_NAME, AttributeCategoryPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return AttributeCategory
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AttributeCategoryPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME);
+ $criteria->add(AttributeCategoryPeer::ID, $pk);
+
+ $v = AttributeCategoryPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return AttributeCategory[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME);
+ $criteria->add(AttributeCategoryPeer::ID, $pks, Criteria::IN);
+ $objs = AttributeCategoryPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAttributeCategoryPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAttributeCategoryPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php
new file mode 100644
index 000000000..69e02fdcb
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php
@@ -0,0 +1,609 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return AttributeCategory|AttributeCategory[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeCategoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeCategory A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CATEGORY_ID`, `ATTRIBUTE_ID`, `CREATED_AT`, `UPDATED_AT` FROM `attribute_category` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new AttributeCategory();
+ $obj->hydrate($row);
+ AttributeCategoryPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeCategory|AttributeCategory[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|AttributeCategory[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AttributeCategoryPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AttributeCategoryPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributeCategoryPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
+ * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
+ * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
+ *
+ *
+ * @see filterByAttribute()
+ *
+ * @param mixed $attributeId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByAttributeId($attributeId = null, $comparison = null)
+ {
+ if (is_array($attributeId)) {
+ $useMinMax = false;
+ if (isset($attributeId['min'])) {
+ $this->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($attributeId['max'])) {
+ $this->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attributeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 AttributeCategoryQuery 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(AttributeCategoryPeer::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCategoryPeer::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 AttributeCategoryQuery 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 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
+ *
+ * @param AttributeCategory $attributeCategory Object to remove from the list of results
+ *
+ * @return AttributeCategoryQuery The current query, for fluid interface
+ */
+ public function prune($attributeCategory = null)
+ {
+ if ($attributeCategory) {
+ $this->addUsingAlias(AttributeCategoryPeer::ID, $attributeCategory->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombination.php b/core/lib/Thelia/Model/om/BaseAttributeCombination.php
new file mode 100644
index 000000000..1962f67ad
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeCombination.php
@@ -0,0 +1,1389 @@
+id;
+ }
+
+ /**
+ * Get the [attribute_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeId()
+ {
+ return $this->attribute_id;
+ }
+
+ /**
+ * Get the [combination_id] column value.
+ *
+ * @return int
+ */
+ public function getCombinationId()
+ {
+ return $this->combination_id;
+ }
+
+ /**
+ * Get the [attribute_av_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeAvId()
+ {
+ return $this->attribute_av_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return AttributeCombination The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeCombinationPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [attribute_id] column.
+ *
+ * @param int $v new value
+ * @return AttributeCombination The current object (for fluent API support)
+ */
+ public function setAttributeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_id !== $v) {
+ $this->attribute_id = $v;
+ $this->modifiedColumns[] = AttributeCombinationPeer::ATTRIBUTE_ID;
+ }
+
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
+
+ return $this;
+ } // setAttributeId()
+
+ /**
+ * Set the value of [combination_id] column.
+ *
+ * @param int $v new value
+ * @return AttributeCombination The current object (for fluent API support)
+ */
+ public function setCombinationId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->combination_id !== $v) {
+ $this->combination_id = $v;
+ $this->modifiedColumns[] = AttributeCombinationPeer::COMBINATION_ID;
+ }
+
+ if ($this->aCombination !== null && $this->aCombination->getId() !== $v) {
+ $this->aCombination = null;
+ }
+
+
+ return $this;
+ } // setCombinationId()
+
+ /**
+ * Set the value of [attribute_av_id] column.
+ *
+ * @param int $v new value
+ * @return AttributeCombination The current object (for fluent API support)
+ */
+ public function setAttributeAvId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_av_id !== $v) {
+ $this->attribute_av_id = $v;
+ $this->modifiedColumns[] = AttributeCombinationPeer::ATTRIBUTE_AV_ID;
+ }
+
+ if ($this->aAttributeAv !== null && $this->aAttributeAv->getId() !== $v) {
+ $this->aAttributeAv = null;
+ }
+
+
+ return $this;
+ } // setAttributeAvId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeCombination The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeCombinationPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeCombination The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeCombinationPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->attribute_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->combination_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->attribute_av_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating AttributeCombination object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AttributeCombinationPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aAttribute = null;
+ $this->aAttributeAv = null;
+ $this->aCombination = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AttributeCombinationQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeCombinationPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeCombinationPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCombinationPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeCombinationPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_ID`';
+ }
+ if ($this->isColumnModified(AttributeCombinationPeer::COMBINATION_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COMBINATION_ID`';
+ }
+ if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_AV_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_AV_ID`';
+ }
+ if ($this->isColumnModified(AttributeCombinationPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `attribute_combination` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`ATTRIBUTE_ID`':
+ $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT);
+ break;
+ case '`COMBINATION_ID`':
+ $stmt->bindValue($identifier, $this->combination_id, PDO::PARAM_INT);
+ break;
+ case '`ATTRIBUTE_AV_ID`':
+ $stmt->bindValue($identifier, $this->attribute_av_id, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeCombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getAttributeId();
+ break;
+ case 2:
+ return $this->getCombinationId();
+ break;
+ case 3:
+ return $this->getAttributeAvId();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeCombination'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeCombination'][serialize($this->getPrimaryKey())] = true;
+ $keys = AttributeCombinationPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAttributeId(),
+ $keys[2] => $this->getCombinationId(),
+ $keys[3] => $this->getAttributeAvId(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aAttributeAv) {
+ $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCombination) {
+ $result['Combination'] = $this->aCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeCombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setAttributeId($value);
+ break;
+ case 2:
+ $this->setCombinationId($value);
+ break;
+ case 3:
+ $this->setAttributeAvId($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AttributeCombinationPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCombinationId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setAttributeAvId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeCombinationPeer::ID)) $criteria->add(AttributeCombinationPeer::ID, $this->id);
+ if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_ID)) $criteria->add(AttributeCombinationPeer::ATTRIBUTE_ID, $this->attribute_id);
+ if ($this->isColumnModified(AttributeCombinationPeer::COMBINATION_ID)) $criteria->add(AttributeCombinationPeer::COMBINATION_ID, $this->combination_id);
+ if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_AV_ID)) $criteria->add(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $this->attribute_av_id);
+ if ($this->isColumnModified(AttributeCombinationPeer::CREATED_AT)) $criteria->add(AttributeCombinationPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) $criteria->add(AttributeCombinationPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME);
+ $criteria->add(AttributeCombinationPeer::ID, $this->id);
+ $criteria->add(AttributeCombinationPeer::ATTRIBUTE_ID, $this->attribute_id);
+ $criteria->add(AttributeCombinationPeer::COMBINATION_ID, $this->combination_id);
+ $criteria->add(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $this->attribute_av_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getAttributeId();
+ $pks[2] = $this->getCombinationId();
+ $pks[3] = $this->getAttributeAvId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setAttributeId($keys[1]);
+ $this->setCombinationId($keys[2]);
+ $this->setAttributeAvId($keys[3]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getAttributeId()) && (null === $this->getCombinationId()) && (null === $this->getAttributeAvId());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of AttributeCombination (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAttributeId($this->getAttributeId());
+ $copyObj->setCombinationId($this->getCombinationId());
+ $copyObj->setAttributeAvId($this->getAttributeAvId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return AttributeCombination Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AttributeCombinationPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AttributeCombinationPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Attribute object.
+ *
+ * @param Attribute $v
+ * @return AttributeCombination 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->addAttributeCombination($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->addAttributeCombinations($this);
+ */
+ }
+
+ return $this->aAttribute;
+ }
+
+ /**
+ * Declares an association between this object and a AttributeAv object.
+ *
+ * @param AttributeAv $v
+ * @return AttributeCombination The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttributeAv(AttributeAv $v = null)
+ {
+ 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;
+ }
+
+
+ /**
+ * 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->addAttributeCombinations($this);
+ */
+ }
+
+ return $this->aAttributeAv;
+ }
+
+ /**
+ * Declares an association between this object and a Combination object.
+ *
+ * @param Combination $v
+ * @return AttributeCombination The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCombination(Combination $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->attribute_id = null;
+ $this->combination_id = null;
+ $this->attribute_av_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aAttribute = null;
+ $this->aAttributeAv = null;
+ $this->aCombination = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeCombinationPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php
new file mode 100644
index 000000000..49bb8677d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php
@@ -0,0 +1,1776 @@
+ array ('Id', 'AttributeId', 'CombinationId', 'AttributeAvId', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'attributeId', 'combinationId', 'attributeAvId', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AttributeCombinationPeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, AttributeCombinationPeer::COMBINATION_ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeCombinationPeer::CREATED_AT, AttributeCombinationPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ATTRIBUTE_ID', 'COMBINATION_ID', 'ATTRIBUTE_AV_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'attribute_id', 'combination_id', 'attribute_av_id', 'created_at', 'updated_At', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AttributeCombinationPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AttributeId' => 1, 'CombinationId' => 2, 'AttributeAvId' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'attributeId' => 1, 'combinationId' => 2, 'attributeAvId' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ BasePeer::TYPE_COLNAME => array (AttributeCombinationPeer::ID => 0, AttributeCombinationPeer::ATTRIBUTE_ID => 1, AttributeCombinationPeer::COMBINATION_ID => 2, AttributeCombinationPeer::ATTRIBUTE_AV_ID => 3, AttributeCombinationPeer::CREATED_AT => 4, AttributeCombinationPeer::UPDATED_AT => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ATTRIBUTE_ID' => 1, 'COMBINATION_ID' => 2, 'ATTRIBUTE_AV_ID' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'attribute_id' => 1, 'combination_id' => 2, 'attribute_av_id' => 3, 'created_at' => 4, 'updated_At' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AttributeCombinationPeer::getFieldNames($toType);
+ $key = isset(AttributeCombinationPeer::$fieldKeys[$fromType][$name]) ? AttributeCombinationPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributeCombinationPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AttributeCombinationPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AttributeCombinationPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AttributeCombinationPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AttributeCombinationPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeCombinationPeer::ID);
+ $criteria->addSelectColumn(AttributeCombinationPeer::ATTRIBUTE_ID);
+ $criteria->addSelectColumn(AttributeCombinationPeer::COMBINATION_ID);
+ $criteria->addSelectColumn(AttributeCombinationPeer::ATTRIBUTE_AV_ID);
+ $criteria->addSelectColumn(AttributeCombinationPeer::CREATED_AT);
+ $criteria->addSelectColumn(AttributeCombinationPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
+ $criteria->addSelectColumn($alias . '.COMBINATION_ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return AttributeCombination
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AttributeCombinationPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AttributeCombinationPeer::populateObjects(AttributeCombinationPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AttributeCombinationPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param AttributeCombination $obj A AttributeCombination object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getAttributeId(), (string) $obj->getCombinationId(), (string) $obj->getAttributeAvId()));
+ } // if key === null
+ AttributeCombinationPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A AttributeCombination object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof AttributeCombination) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getAttributeId(), (string) $value->getCombinationId(), (string) $value->getAttributeAvId()));
+ } elseif (is_array($value) && count($value) === 4) {
+ // assume we've been passed a primary key
+ $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2], (string) $value[3]));
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AttributeCombination object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AttributeCombinationPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return AttributeCombination Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AttributeCombinationPeer::$instances[$key])) {
+ return AttributeCombinationPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AttributeCombinationPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to attribute_combination
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null && $row[$startcol + 1] === null && $row[$startcol + 2] === null && $row[$startcol + 3] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1], (string) $row[$startcol + 2], (string) $row[$startcol + 3]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return array((int) $row[$startcol], (int) $row[$startcol + 1], (int) $row[$startcol + 2], (int) $row[$startcol + 3]);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AttributeCombinationPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AttributeCombinationPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeCombinationPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeCombination object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AttributeCombinationPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeCombinationPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AttributeCombinationPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AttributeCombinationPeer::DATABASE_NAME)->getTable(AttributeCombinationPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAttributeCombinationPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAttributeCombinationPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeCombinationTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AttributeCombinationPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeCombination or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeCombination object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from AttributeCombination object
+ }
+
+ if ($criteria->containsKey(AttributeCombinationPeer::ID) && $criteria->keyContainsValue(AttributeCombinationPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCombinationPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a AttributeCombination or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeCombination object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AttributeCombinationPeer::ID);
+ $value = $criteria->remove(AttributeCombinationPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AttributeCombinationPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(AttributeCombinationPeer::ATTRIBUTE_ID);
+ $value = $criteria->remove(AttributeCombinationPeer::ATTRIBUTE_ID);
+ if ($value) {
+ $selectCriteria->add(AttributeCombinationPeer::ATTRIBUTE_ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(AttributeCombinationPeer::COMBINATION_ID);
+ $value = $criteria->remove(AttributeCombinationPeer::COMBINATION_ID);
+ if ($value) {
+ $selectCriteria->add(AttributeCombinationPeer::COMBINATION_ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(AttributeCombinationPeer::ATTRIBUTE_AV_ID);
+ $value = $criteria->remove(AttributeCombinationPeer::ATTRIBUTE_AV_ID);
+ if ($value) {
+ $selectCriteria->add(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME);
+ }
+
+ } else { // $values is AttributeCombination object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_combination table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ AttributeCombinationPeer::clearInstancePool();
+ AttributeCombinationPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeCombination or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeCombination object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(AttributeCombinationPeer::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_ID, $value[1]));
+ $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);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AttributeCombinationPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given AttributeCombination object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param AttributeCombination $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AttributeCombinationPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AttributeCombinationPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AttributeCombinationPeer::DATABASE_NAME, AttributeCombinationPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve object using using composite pkey values.
+ * @param int $id
+ * @param int $attribute_id
+ * @param int $combination_id
+ * @param int $attribute_av_id
+ * @param PropelPDO $con
+ * @return AttributeCombination
+ */
+ public static function retrieveByPK($id, $attribute_id, $combination_id, $attribute_av_id, PropelPDO $con = null) {
+ $_instancePoolKey = serialize(array((string) $id, (string) $attribute_id, (string) $combination_id, (string) $attribute_av_id));
+ if (null !== ($obj = AttributeCombinationPeer::getInstanceFromPool($_instancePoolKey))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $criteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME);
+ $criteria->add(AttributeCombinationPeer::ID, $id);
+ $criteria->add(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute_id);
+ $criteria->add(AttributeCombinationPeer::COMBINATION_ID, $combination_id);
+ $criteria->add(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attribute_av_id);
+ $v = AttributeCombinationPeer::doSelect($criteria, $con);
+
+ return !empty($v) ? $v[0] : null;
+ }
+} // BaseAttributeCombinationPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAttributeCombinationPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php
new file mode 100644
index 000000000..2d6edd41d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php
@@ -0,0 +1,720 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34, 56, 78), $con);
+ *
+ *
+ * @param array $key Primary key to use for the query
+ A Primary key composition: [$id, $attribute_id, $combination_id, $attribute_av_id]
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return AttributeCombination|AttributeCombination[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeCombinationPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3]))))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeCombination A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `ATTRIBUTE_ID`, `COMBINATION_ID`, `ATTRIBUTE_AV_ID`, `CREATED_AT`, `UPDATED_AT` FROM `attribute_combination` WHERE `ID` = :p0 AND `ATTRIBUTE_ID` = :p1 AND `COMBINATION_ID` = :p2 AND `ATTRIBUTE_AV_ID` = :p3';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT);
+ $stmt->bindValue(':p3', $key[3], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new AttributeCombination();
+ $obj->hydrate($row);
+ AttributeCombinationPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeCombination|AttributeCombination[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|AttributeCombination[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(AttributeCombinationPeer::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $key[1], Criteria::EQUAL);
+ $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $key[2], Criteria::EQUAL);
+ $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(AttributeCombinationPeer::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $cton2 = $this->getNewCriterion(AttributeCombinationPeer::COMBINATION_ID, $key[2], Criteria::EQUAL);
+ $cton0->addAnd($cton2);
+ $cton3 = $this->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL);
+ $cton0->addAnd($cton3);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributeCombinationPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
+ * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
+ * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
+ *
+ *
+ * @see filterByAttribute()
+ *
+ * @param mixed $attributeId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByAttributeId($attributeId = null, $comparison = null)
+ {
+ if (is_array($attributeId) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the combination_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCombinationId(1234); // WHERE combination_id = 1234
+ * $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34)
+ * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12
+ *
+ *
+ * @see filterByCombination()
+ *
+ * @param mixed $combinationId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByCombinationId($combinationId = null, $comparison = null)
+ {
+ if (is_array($combinationId) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_av_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeAvId(1234); // WHERE attribute_av_id = 1234
+ * $query->filterByAttributeAvId(array(12, 34)); // WHERE attribute_av_id IN (12, 34)
+ * $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id > 12
+ *
+ *
+ * @see filterByAttributeAv()
+ *
+ * @param mixed $attributeAvId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByAttributeAvId($attributeAvId = null, $comparison = null)
+ {
+ if (is_array($attributeAvId) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAvId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_At column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_At = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_At = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_At > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCombinationPeer::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 AttributeCombinationQuery 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(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison);
+ } elseif ($attribute instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCombinationPeer::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 AttributeCombinationQuery 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 AttributeAv object
+ *
+ * @param AttributeAv|PropelObjectCollection $attributeAv The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeAv($attributeAv, $comparison = null)
+ {
+ if ($attributeAv instanceof AttributeAv) {
+ return $this
+ ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison);
+ } elseif ($attributeAv instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeAv');
+
+ // 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, 'AttributeAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeAv relation AttributeAv 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\AttributeAvQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery');
+ }
+
+ /**
+ * Filter the query by a related Combination object
+ *
+ * @param Combination|PropelObjectCollection $combination The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCombination($combination, $comparison = null)
+ {
+ if ($combination instanceof Combination) {
+ return $this
+ ->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combination->getId(), $comparison);
+ } elseif ($combination instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCombination() only accepts arguments of type Combination or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Combination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function joinCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Combination');
+
+ // 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, 'Combination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Combination relation Combination 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\CombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Combination', '\Thelia\Model\CombinationQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param AttributeCombination $attributeCombination Object to remove from the list of results
+ *
+ * @return AttributeCombinationQuery The current query, for fluid interface
+ */
+ public function prune($attributeCombination = null)
+ {
+ if ($attributeCombination) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(AttributeCombinationPeer::ID), $attributeCombination->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(AttributeCombinationPeer::ATTRIBUTE_ID), $attributeCombination->getAttributeId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond2', $this->getAliasedColName(AttributeCombinationPeer::COMBINATION_ID), $attributeCombination->getCombinationId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond3', $this->getAliasedColName(AttributeCombinationPeer::ATTRIBUTE_AV_ID), $attributeCombination->getAttributeAvId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2', 'pruneCond3'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeDesc.php b/core/lib/Thelia/Model/om/BaseAttributeDesc.php
new file mode 100644
index 000000000..9f0247632
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeDesc.php
@@ -0,0 +1,1320 @@
+id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [attribute_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeId()
+ {
+ return $this->attribute_id;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return AttributeDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return AttributeDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = AttributeDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [attribute_id] column.
+ *
+ * @param int $v new value
+ * @return AttributeDesc The current object (for fluent API support)
+ */
+ public function setAttributeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_id !== $v) {
+ $this->attribute_id = $v;
+ $this->modifiedColumns[] = AttributeDescPeer::ATTRIBUTE_ID;
+ }
+
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
+
+ return $this;
+ } // setAttributeId()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return AttributeDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = AttributeDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return AttributeDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = AttributeDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return AttributeDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = AttributeDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return AttributeDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = AttributeDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->lang = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->attribute_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = AttributeDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating AttributeDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = AttributeDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aAttribute = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = AttributeDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(AttributeDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(AttributeDescPeer::ATTRIBUTE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_ID`';
+ }
+ if ($this->isColumnModified(AttributeDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(AttributeDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(AttributeDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(AttributeDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(AttributeDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `attribute_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`ATTRIBUTE_ID`':
+ $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getLang();
+ break;
+ case 2:
+ return $this->getAttributeId();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeDesc'][$this->getPrimaryKey()] = true;
+ $keys = AttributeDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLang(),
+ $keys[2] => $this->getAttributeId(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = AttributeDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setLang($value);
+ break;
+ case 2:
+ $this->setAttributeId($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = AttributeDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLang($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAttributeId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(AttributeDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeDescPeer::ID)) $criteria->add(AttributeDescPeer::ID, $this->id);
+ if ($this->isColumnModified(AttributeDescPeer::LANG)) $criteria->add(AttributeDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(AttributeDescPeer::ATTRIBUTE_ID)) $criteria->add(AttributeDescPeer::ATTRIBUTE_ID, $this->attribute_id);
+ if ($this->isColumnModified(AttributeDescPeer::TITLE)) $criteria->add(AttributeDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(AttributeDescPeer::DESCRIPTION)) $criteria->add(AttributeDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(AttributeDescPeer::CHAPO)) $criteria->add(AttributeDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(AttributeDescPeer::CREATED_AT)) $criteria->add(AttributeDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeDescPeer::UPDATED_AT)) $criteria->add(AttributeDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(AttributeDescPeer::DATABASE_NAME);
+ $criteria->add(AttributeDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of AttributeDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setLang($this->getLang());
+ $copyObj->setAttributeId($this->getAttributeId());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return AttributeDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return AttributeDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new AttributeDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Attribute object.
+ *
+ * @param Attribute $v
+ * @return AttributeDesc 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->lang = null;
+ $this->attribute_id = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aAttribute = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributeDescPeer.php b/core/lib/Thelia/Model/om/BaseAttributeDescPeer.php
new file mode 100644
index 000000000..4dd4dd57d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeDescPeer.php
@@ -0,0 +1,1037 @@
+ array ('Id', 'Lang', 'AttributeId', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'lang', 'attributeId', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AttributeDescPeer::ID, AttributeDescPeer::LANG, AttributeDescPeer::ATTRIBUTE_ID, AttributeDescPeer::TITLE, AttributeDescPeer::DESCRIPTION, AttributeDescPeer::CHAPO, AttributeDescPeer::CREATED_AT, AttributeDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LANG', 'ATTRIBUTE_ID', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'lang', 'attribute_id', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AttributeDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Lang' => 1, 'AttributeId' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'lang' => 1, 'attributeId' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (AttributeDescPeer::ID => 0, AttributeDescPeer::LANG => 1, AttributeDescPeer::ATTRIBUTE_ID => 2, AttributeDescPeer::TITLE => 3, AttributeDescPeer::DESCRIPTION => 4, AttributeDescPeer::CHAPO => 5, AttributeDescPeer::CREATED_AT => 6, AttributeDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LANG' => 1, 'ATTRIBUTE_ID' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'lang' => 1, 'attribute_id' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AttributeDescPeer::getFieldNames($toType);
+ $key = isset(AttributeDescPeer::$fieldKeys[$fromType][$name]) ? AttributeDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributeDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AttributeDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AttributeDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AttributeDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AttributeDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeDescPeer::ID);
+ $criteria->addSelectColumn(AttributeDescPeer::LANG);
+ $criteria->addSelectColumn(AttributeDescPeer::ATTRIBUTE_ID);
+ $criteria->addSelectColumn(AttributeDescPeer::TITLE);
+ $criteria->addSelectColumn(AttributeDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(AttributeDescPeer::CHAPO);
+ $criteria->addSelectColumn(AttributeDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(AttributeDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return AttributeDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AttributeDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AttributeDescPeer::populateObjects(AttributeDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AttributeDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param AttributeDesc $obj A AttributeDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AttributeDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A AttributeDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof AttributeDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AttributeDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AttributeDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return AttributeDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AttributeDescPeer::$instances[$key])) {
+ return AttributeDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AttributeDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to attribute_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AttributeDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AttributeDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AttributeDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AttributeDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AttributeDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AttributeDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AttributeDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AttributeDescPeer::DATABASE_NAME)->getTable(AttributeDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAttributeDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAttributeDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AttributeDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from AttributeDesc object
+ }
+
+ if ($criteria->containsKey(AttributeDescPeer::ID) && $criteria->keyContainsValue(AttributeDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a AttributeDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or AttributeDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AttributeDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AttributeDescPeer::ID);
+ $value = $criteria->remove(AttributeDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(AttributeDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributeDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is AttributeDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ AttributeDescPeer::clearInstancePool();
+ AttributeDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(AttributeDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AttributeDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given AttributeDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param AttributeDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AttributeDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AttributeDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AttributeDescPeer::DATABASE_NAME, AttributeDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return AttributeDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AttributeDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AttributeDescPeer::DATABASE_NAME);
+ $criteria->add(AttributeDescPeer::ID, $pk);
+
+ $v = AttributeDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return AttributeDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AttributeDescPeer::DATABASE_NAME);
+ $criteria->add(AttributeDescPeer::ID, $pks, Criteria::IN);
+ $objs = AttributeDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAttributeDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAttributeDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php b/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php
new file mode 100644
index 000000000..421f6279c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php
@@ -0,0 +1,613 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return AttributeDesc|AttributeDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AttributeDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `LANG`, `ATTRIBUTE_ID`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `attribute_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new AttributeDesc();
+ $obj->hydrate($row);
+ AttributeDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return AttributeDesc|AttributeDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|AttributeDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AttributeDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AttributeDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributeDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
+ * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
+ * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
+ *
+ *
+ * @see filterByAttribute()
+ *
+ * @param mixed $attributeId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByAttributeId($attributeId = null, $comparison = null)
+ {
+ if (is_array($attributeId)) {
+ $useMinMax = false;
+ if (isset($attributeId['min'])) {
+ $this->addUsingAlias(AttributeDescPeer::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($attributeId['max'])) {
+ $this->addUsingAlias(AttributeDescPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeDescPeer::ATTRIBUTE_ID, $attributeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeDescPeer::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 AttributeDescQuery 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(AttributeDescPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison);
+ } elseif ($attribute instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeDescPeer::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 AttributeDescQuery 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
+ *
+ * @param AttributeDesc $attributeDesc Object to remove from the list of results
+ *
+ * @return AttributeDescQuery The current query, for fluid interface
+ */
+ public function prune($attributeDesc = null)
+ {
+ if ($attributeDesc) {
+ $this->addUsingAlias(AttributeDescPeer::ID, $attributeDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseAttributePeer.php b/core/lib/Thelia/Model/om/BaseAttributePeer.php
new file mode 100644
index 000000000..33e211dc0
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributePeer.php
@@ -0,0 +1,794 @@
+ array ('Id', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (AttributePeer::ID, AttributePeer::POSITION, AttributePeer::CREATED_AT, AttributePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. AttributePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Position' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'position' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ BasePeer::TYPE_COLNAME => array (AttributePeer::ID => 0, AttributePeer::POSITION => 1, AttributePeer::CREATED_AT => 2, AttributePeer::UPDATED_AT => 3, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'POSITION' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'position' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = AttributePeer::getFieldNames($toType);
+ $key = isset(AttributePeer::$fieldKeys[$fromType][$name]) ? AttributePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, AttributePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return AttributePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. AttributePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(AttributePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributePeer::ID);
+ $criteria->addSelectColumn(AttributePeer::POSITION);
+ $criteria->addSelectColumn(AttributePeer::CREATED_AT);
+ $criteria->addSelectColumn(AttributePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(AttributePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Attribute
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = AttributePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return AttributePeer::populateObjects(AttributePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ AttributePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Attribute $obj A Attribute object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ AttributePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Attribute object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Attribute) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Attribute object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(AttributePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Attribute Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(AttributePeer::$instances[$key])) {
+ return AttributePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ AttributePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to attribute
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = AttributePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = AttributePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = AttributePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Attribute object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = AttributePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + AttributePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ AttributePeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(AttributePeer::DATABASE_NAME)->getTable(AttributePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseAttributePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseAttributePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return AttributePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Attribute or Criteria object.
+ *
+ * @param mixed $values Criteria or Attribute object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Attribute object
+ }
+
+ if ($criteria->containsKey(AttributePeer::ID) && $criteria->keyContainsValue(AttributePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Attribute or Criteria object.
+ *
+ * @param mixed $values Criteria or Attribute object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(AttributePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(AttributePeer::ID);
+ $value = $criteria->remove(AttributePeer::ID);
+ if ($value) {
+ $selectCriteria->add(AttributePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(AttributePeer::TABLE_NAME);
+ }
+
+ } else { // $values is Attribute object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(AttributePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the attribute table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(AttributePeer::TABLE_NAME, $con, AttributePeer::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
+ // instances get re-added by the select statement contained therein).
+ AttributePeer::clearInstancePool();
+ AttributePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Attribute or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Attribute object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ AttributePeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Attribute) { // it's a model object
+ // invalidate the cache for this single object
+ AttributePeer::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(AttributePeer::DATABASE_NAME);
+ $criteria->add(AttributePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ AttributePeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ AttributePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Attribute object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Attribute $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(AttributePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(AttributePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(AttributePeer::DATABASE_NAME, AttributePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Attribute
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = AttributePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(AttributePeer::DATABASE_NAME);
+ $criteria->add(AttributePeer::ID, $pk);
+
+ $v = AttributePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Attribute[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(AttributePeer::DATABASE_NAME);
+ $criteria->add(AttributePeer::ID, $pks, Criteria::IN);
+ $objs = AttributePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseAttributePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseAttributePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseAttributeQuery.php b/core/lib/Thelia/Model/om/BaseAttributeQuery.php
new file mode 100644
index 000000000..15ca7f633
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseAttributeQuery.php
@@ -0,0 +1,714 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Attribute|Attribute[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Attribute A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `attribute` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Attribute();
+ $obj->hydrate($row);
+ AttributePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Attribute|Attribute[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Attribute[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AttributePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AttributePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(AttributePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(AttributePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(AttributePeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributePeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related AttributeAv object
+ *
+ * @param AttributeAv|PropelObjectCollection $attributeAv the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeAv($attributeAv, $comparison = null)
+ {
+ if ($attributeAv instanceof AttributeAv) {
+ return $this
+ ->addUsingAlias(AttributePeer::ID, $attributeAv->getAttributeId(), $comparison);
+ } elseif ($attributeAv instanceof PropelObjectCollection) {
+ return $this
+ ->useAttributeAvQuery()
+ ->filterByPrimaryKeys($attributeAv->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeAv');
+
+ // 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, 'AttributeAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeAv relation AttributeAv 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\AttributeAvQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery');
+ }
+
+ /**
+ * Filter the query by a related AttributeCategory object
+ *
+ * @param AttributeCategory|PropelObjectCollection $attributeCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeCategory($attributeCategory, $comparison = null)
+ {
+ if ($attributeCategory instanceof AttributeCategory) {
+ return $this
+ ->addUsingAlias(AttributePeer::ID, $attributeCategory->getAttributeId(), $comparison);
+ } elseif ($attributeCategory instanceof PropelObjectCollection) {
+ return $this
+ ->useAttributeCategoryQuery()
+ ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCategory relation AttributeCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related AttributeCombination object
+ *
+ * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeCombination($attributeCombination, $comparison = null)
+ {
+ if ($attributeCombination instanceof AttributeCombination) {
+ return $this
+ ->addUsingAlias(AttributePeer::ID, $attributeCombination->getAttributeId(), $comparison);
+ } elseif ($attributeCombination instanceof PropelObjectCollection) {
+ return $this
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCombination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCombination');
+
+ // 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, 'AttributeCombination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCombination relation AttributeCombination 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\AttributeCombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery');
+ }
+
+ /**
+ * Filter the query by a related AttributeDesc object
+ *
+ * @param AttributeDesc|PropelObjectCollection $attributeDesc the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeDesc($attributeDesc, $comparison = null)
+ {
+ if ($attributeDesc instanceof AttributeDesc) {
+ return $this
+ ->addUsingAlias(AttributePeer::ID, $attributeDesc->getAttributeId(), $comparison);
+ } elseif ($attributeDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useAttributeDescQuery()
+ ->filterByPrimaryKeys($attributeDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeDesc() only accepts arguments of type AttributeDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function joinAttributeDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeDesc');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeDesc relation AttributeDesc object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeDescQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeDesc', '\Thelia\Model\AttributeDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Attribute $attribute Object to remove from the list of results
+ *
+ * @return AttributeQuery The current query, for fluid interface
+ */
+ public function prune($attribute = null)
+ {
+ if ($attribute) {
+ $this->addUsingAlias(AttributePeer::ID, $attribute->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCategory.php b/core/lib/Thelia/Model/om/BaseCategory.php
new file mode 100644
index 000000000..75729a095
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategory.php
@@ -0,0 +1,3692 @@
+id;
+ }
+
+ /**
+ * Get the [parent] column value.
+ *
+ * @return int
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Get the [link] column value.
+ *
+ * @return string
+ */
+ public function getLink()
+ {
+ return $this->link;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Category The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CategoryPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return Category The current object (for fluent API support)
+ */
+ public function setParent($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent !== $v) {
+ $this->parent = $v;
+ $this->modifiedColumns[] = CategoryPeer::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Set the value of [link] column.
+ *
+ * @param string $v new value
+ * @return Category The current object (for fluent API support)
+ */
+ public function setLink($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->link !== $v) {
+ $this->link = $v;
+ $this->modifiedColumns[] = CategoryPeer::LINK;
+ }
+
+
+ return $this;
+ } // setLink()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return Category The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = CategoryPeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Category The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = CategoryPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Category The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CategoryPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Category The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CategoryPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->parent = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->link = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->visible = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = CategoryPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Category object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $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)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CategoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CategoryPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CategoryPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CategoryPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CategoryPeer::PARENT)) {
+ $modifiedColumns[':p' . $index++] = '`PARENT`';
+ }
+ if ($this->isColumnModified(CategoryPeer::LINK)) {
+ $modifiedColumns[':p' . $index++] = '`LINK`';
+ }
+ if ($this->isColumnModified(CategoryPeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(CategoryPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(CategoryPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `category` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`PARENT`':
+ $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
+ break;
+ case '`LINK`':
+ $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
+ break;
+ case '`VISIBLE`':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getParent();
+ break;
+ case 2:
+ return $this->getLink();
+ break;
+ case 3:
+ return $this->getVisible();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Category'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Category'][$this->getPrimaryKey()] = true;
+ $keys = CategoryPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getParent(),
+ $keys[2] => $this->getLink(),
+ $keys[3] => $this->getVisible(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collAttributeCategorys) {
+ $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCategoryDescs) {
+ $result['CategoryDescs'] = $this->collCategoryDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureCategorys) {
+ $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collProductCategorys) {
+ $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setParent($value);
+ break;
+ case 2:
+ $this->setLink($value);
+ break;
+ case 3:
+ $this->setVisible($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CategoryPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CategoryPeer::ID)) $criteria->add(CategoryPeer::ID, $this->id);
+ if ($this->isColumnModified(CategoryPeer::PARENT)) $criteria->add(CategoryPeer::PARENT, $this->parent);
+ if ($this->isColumnModified(CategoryPeer::LINK)) $criteria->add(CategoryPeer::LINK, $this->link);
+ if ($this->isColumnModified(CategoryPeer::VISIBLE)) $criteria->add(CategoryPeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(CategoryPeer::POSITION)) $criteria->add(CategoryPeer::POSITION, $this->position);
+ if ($this->isColumnModified(CategoryPeer::CREATED_AT)) $criteria->add(CategoryPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) $criteria->add(CategoryPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
+ $criteria->add(CategoryPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Category (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setParent($this->getParent());
+ $copyObj->setLink($this->getLink());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getAttributeCategorys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCategoryDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCategoryDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentAssocs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentAssoc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDocuments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocument($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureCategorys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getImages() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImage($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getProductCategorys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProductCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Category Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CategoryPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CategoryPeer();
+ }
+
+ 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.
+ *
+ * @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 getAttributeCategorys($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collAttributeCategorysPartial && !$this->isNew();
+ if (null === $this->collAttributeCategorys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCategorys) {
+ // return empty collection
+ $this->initAttributeCategorys();
+ } else {
+ $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria)
+ ->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 {
+ return count($this->collAttributeCategorys);
+ }
+ }
+
+ /**
+ * Method called to associate a AttributeCategory object to this object
+ * through the AttributeCategory foreign key attribute.
+ *
+ * @param AttributeCategory $l AttributeCategory
+ * @return 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;
+ }
+
+ /**
+ * @param AttributeCategory $attributeCategory The attributeCategory object to add.
+ */
+ protected function doAddAttributeCategory($attributeCategory)
+ {
+ $this->collAttributeCategorys[]= $attributeCategory;
+ $attributeCategory->setCategory($this);
+ }
+
+ /**
+ * @param AttributeCategory $attributeCategory The attributeCategory object to remove.
+ */
+ public function removeAttributeCategory($attributeCategory)
+ {
+ if ($this->getAttributeCategorys()->contains($attributeCategory)) {
+ $this->collAttributeCategorys->remove($this->collAttributeCategorys->search($attributeCategory));
+ if (null === $this->attributeCategorysScheduledForDeletion) {
+ $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys;
+ $this->attributeCategorysScheduledForDeletion->clear();
+ }
+ $this->attributeCategorysScheduledForDeletion[]= $attributeCategory;
+ $attributeCategory->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.
+ *
+ * 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 getCategoryDescs($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collCategoryDescsPartial && !$this->isNew();
+ if (null === $this->collCategoryDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCategoryDescs) {
+ // return empty collection
+ $this->initCategoryDescs();
+ } else {
+ $collCategoryDescs = CategoryDescQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCategoryDescsPartial && count($collCategoryDescs)) {
+ $this->initCategoryDescs(false);
+
+ foreach($collCategoryDescs as $obj) {
+ if (false == $this->collCategoryDescs->contains($obj)) {
+ $this->collCategoryDescs->append($obj);
+ }
+ }
+
+ $this->collCategoryDescsPartial = true;
+ }
+
+ return $collCategoryDescs;
+ }
+
+ if($partial && $this->collCategoryDescs) {
+ foreach($this->collCategoryDescs as $obj) {
+ if($obj->isNew()) {
+ $collCategoryDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collCategoryDescs = $collCategoryDescs;
+ $this->collCategoryDescsPartial = false;
+ }
+ }
+
+ return $this->collCategoryDescs;
+ }
+
+ /**
+ * Sets a collection of CategoryDesc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $categoryDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setCategoryDescs(PropelCollection $categoryDescs, PropelPDO $con = null)
+ {
+ $this->categoryDescsScheduledForDeletion = $this->getCategoryDescs(new Criteria(), $con)->diff($categoryDescs);
+
+ foreach ($this->categoryDescsScheduledForDeletion as $categoryDescRemoved) {
+ $categoryDescRemoved->setCategory(null);
+ }
+
+ $this->collCategoryDescs = null;
+ foreach ($categoryDescs as $categoryDesc) {
+ $this->addCategoryDesc($categoryDesc);
+ }
+
+ $this->collCategoryDescs = $categoryDescs;
+ $this->collCategoryDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related CategoryDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CategoryDesc objects.
+ * @throws PropelException
+ */
+ public function countCategoryDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCategoryDescsPartial && !$this->isNew();
+ if (null === $this->collCategoryDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCategoryDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getCategoryDescs());
+ }
+ $query = CategoryDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCategoryDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a CategoryDesc object to this object
+ * through the CategoryDesc foreign key attribute.
+ *
+ * @param CategoryDesc $l CategoryDesc
+ * @return Category The current object (for fluent API support)
+ */
+ public function addCategoryDesc(CategoryDesc $l)
+ {
+ if ($this->collCategoryDescs === null) {
+ $this->initCategoryDescs();
+ $this->collCategoryDescsPartial = true;
+ }
+ if (!$this->collCategoryDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddCategoryDesc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CategoryDesc $categoryDesc The categoryDesc object to add.
+ */
+ protected function doAddCategoryDesc($categoryDesc)
+ {
+ $this->collCategoryDescs[]= $categoryDesc;
+ $categoryDesc->setCategory($this);
+ }
+
+ /**
+ * @param CategoryDesc $categoryDesc The categoryDesc object to remove.
+ */
+ public function removeCategoryDesc($categoryDesc)
+ {
+ if ($this->getCategoryDescs()->contains($categoryDesc)) {
+ $this->collCategoryDescs->remove($this->collCategoryDescs->search($categoryDesc));
+ if (null === $this->categoryDescsScheduledForDeletion) {
+ $this->categoryDescsScheduledForDeletion = clone $this->collCategoryDescs;
+ $this->categoryDescsScheduledForDeletion->clear();
+ }
+ $this->categoryDescsScheduledForDeletion[]= $categoryDesc;
+ $categoryDesc->setCategory(null);
+ }
+ }
+
+ /**
+ * Clears out the collContentAssocs collection
+ *
+ * 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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param ContentAssoc $contentAssoc The contentAssoc object to add.
+ */
+ protected function doAddContentAssoc($contentAssoc)
+ {
+ $this->collContentAssocs[]= $contentAssoc;
+ $contentAssoc->setCategory($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->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.
+ *
+ * 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 getDocuments($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ // return empty collection
+ $this->initDocuments();
+ } else {
+ $collDocuments = DocumentQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentsPartial && count($collDocuments)) {
+ $this->initDocuments(false);
+
+ foreach($collDocuments as $obj) {
+ if (false == $this->collDocuments->contains($obj)) {
+ $this->collDocuments->append($obj);
+ }
+ }
+
+ $this->collDocumentsPartial = true;
+ }
+
+ return $collDocuments;
+ }
+
+ if($partial && $this->collDocuments) {
+ foreach($this->collDocuments as $obj) {
+ if($obj->isNew()) {
+ $collDocuments[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocuments = $collDocuments;
+ $this->collDocumentsPartial = false;
+ }
+ }
+
+ return $this->collDocuments;
+ }
+
+ /**
+ * Sets a collection of Document objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $documents A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setDocuments(PropelCollection $documents, PropelPDO $con = null)
+ {
+ $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents);
+
+ foreach ($this->documentsScheduledForDeletion as $documentRemoved) {
+ $documentRemoved->setCategory(null);
+ }
+
+ $this->collDocuments = null;
+ foreach ($documents as $document) {
+ $this->addDocument($document);
+ }
+
+ $this->collDocuments = $documents;
+ $this->collDocumentsPartial = false;
+ }
+
+ /**
+ * Returns the number of related Document objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Document objects.
+ * @throws PropelException
+ */
+ public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getDocuments());
+ }
+ $query = DocumentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collDocuments);
+ }
+ }
+
+ /**
+ * Method called to associate a Document object to this object
+ * through the Document foreign key attribute.
+ *
+ * @param Document $l Document
+ * @return Category The current object (for fluent API support)
+ */
+ public function addDocument(Document $l)
+ {
+ if ($this->collDocuments === null) {
+ $this->initDocuments();
+ $this->collDocumentsPartial = true;
+ }
+ if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddDocument($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Document $document The document object to add.
+ */
+ protected function doAddDocument($document)
+ {
+ $this->collDocuments[]= $document;
+ $document->setCategory($this);
+ }
+
+ /**
+ * @param Document $document The document object to remove.
+ */
+ public function removeDocument($document)
+ {
+ if ($this->getDocuments()->contains($document)) {
+ $this->collDocuments->remove($this->collDocuments->search($document));
+ if (null === $this->documentsScheduledForDeletion) {
+ $this->documentsScheduledForDeletion = clone $this->collDocuments;
+ $this->documentsScheduledForDeletion->clear();
+ }
+ $this->documentsScheduledForDeletion[]= $document;
+ $document->setCategory(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Content', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Folder', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+ /**
+ * Clears out the collFeatureCategorys collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureCategorys()
+ */
+ public function clearFeatureCategorys()
+ {
+ $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized
+ $this->collFeatureCategorysPartial = null;
+ }
+
+ /**
+ * reset is the collFeatureCategorys collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialFeatureCategorys($v = true)
+ {
+ $this->collFeatureCategorysPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureCategorys collection.
+ *
+ * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureCategorys($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureCategorys && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureCategorys = new PropelObjectCollection();
+ $this->collFeatureCategorys->setModel('FeatureCategory');
+ }
+
+ /**
+ * Gets an array of FeatureCategory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this Category is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects
+ * @throws PropelException
+ */
+ public function getFeatureCategorys($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collFeatureCategorysPartial && !$this->isNew();
+ if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureCategorys) {
+ // return empty collection
+ $this->initFeatureCategorys();
+ } else {
+ $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) {
+ $this->initFeatureCategorys(false);
+
+ foreach($collFeatureCategorys as $obj) {
+ if (false == $this->collFeatureCategorys->contains($obj)) {
+ $this->collFeatureCategorys->append($obj);
+ }
+ }
+
+ $this->collFeatureCategorysPartial = true;
+ }
+
+ return $collFeatureCategorys;
+ }
+
+ if($partial && $this->collFeatureCategorys) {
+ foreach($this->collFeatureCategorys as $obj) {
+ if($obj->isNew()) {
+ $collFeatureCategorys[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureCategorys = $collFeatureCategorys;
+ $this->collFeatureCategorysPartial = false;
+ }
+ }
+
+ return $this->collFeatureCategorys;
+ }
+
+ /**
+ * Sets a collection of FeatureCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $featureCategorys A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null)
+ {
+ $this->featureCategorysScheduledForDeletion = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys);
+
+ foreach ($this->featureCategorysScheduledForDeletion as $featureCategoryRemoved) {
+ $featureCategoryRemoved->setCategory(null);
+ }
+
+ $this->collFeatureCategorys = null;
+ foreach ($featureCategorys as $featureCategory) {
+ $this->addFeatureCategory($featureCategory);
+ }
+
+ $this->collFeatureCategorys = $featureCategorys;
+ $this->collFeatureCategorysPartial = false;
+ }
+
+ /**
+ * Returns the number of related FeatureCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related FeatureCategory objects.
+ * @throws PropelException
+ */
+ public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collFeatureCategorysPartial && !$this->isNew();
+ if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureCategorys) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getFeatureCategorys());
+ }
+ $query = FeatureCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collFeatureCategorys);
+ }
+ }
+
+ /**
+ * Method called to associate a FeatureCategory object to this object
+ * through the FeatureCategory foreign key attribute.
+ *
+ * @param FeatureCategory $l FeatureCategory
+ * @return Category The current object (for fluent API support)
+ */
+ public function addFeatureCategory(FeatureCategory $l)
+ {
+ if ($this->collFeatureCategorys === null) {
+ $this->initFeatureCategorys();
+ $this->collFeatureCategorysPartial = true;
+ }
+ if (!$this->collFeatureCategorys->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureCategory $featureCategory The featureCategory object to add.
+ */
+ protected function doAddFeatureCategory($featureCategory)
+ {
+ $this->collFeatureCategorys[]= $featureCategory;
+ $featureCategory->setCategory($this);
+ }
+
+ /**
+ * @param FeatureCategory $featureCategory The featureCategory object to remove.
+ */
+ public function removeFeatureCategory($featureCategory)
+ {
+ if ($this->getFeatureCategorys()->contains($featureCategory)) {
+ $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory));
+ if (null === $this->featureCategorysScheduledForDeletion) {
+ $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys;
+ $this->featureCategorysScheduledForDeletion->clear();
+ }
+ $this->featureCategorysScheduledForDeletion[]= $featureCategory;
+ $featureCategory->setCategory(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related FeatureCategorys from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects
+ */
+ public function getFeatureCategorysJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = FeatureCategoryQuery::create(null, $criteria);
+ $query->joinWith('Feature', $join_behavior);
+
+ return $this->getFeatureCategorys($query, $con);
+ }
+
+ /**
+ * Clears out the collImages collection
+ *
+ * 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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param Image $image The image object to add.
+ */
+ protected function doAddImage($image)
+ {
+ $this->collImages[]= $image;
+ $image->setCategory($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->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.
+ *
+ * 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 getProductCategorys($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collProductCategorysPartial && !$this->isNew();
+ if (null === $this->collProductCategorys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductCategorys) {
+ // return empty collection
+ $this->initProductCategorys();
+ } else {
+ $collProductCategorys = ProductCategoryQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) {
+ $this->initProductCategorys(false);
+
+ foreach($collProductCategorys as $obj) {
+ if (false == $this->collProductCategorys->contains($obj)) {
+ $this->collProductCategorys->append($obj);
+ }
+ }
+
+ $this->collProductCategorysPartial = true;
+ }
+
+ return $collProductCategorys;
+ }
+
+ if($partial && $this->collProductCategorys) {
+ foreach($this->collProductCategorys as $obj) {
+ if($obj->isNew()) {
+ $collProductCategorys[] = $obj;
+ }
+ }
+ }
+
+ $this->collProductCategorys = $collProductCategorys;
+ $this->collProductCategorysPartial = false;
+ }
+ }
+
+ return $this->collProductCategorys;
+ }
+
+ /**
+ * Sets a collection of ProductCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $productCategorys A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null)
+ {
+ $this->productCategorysScheduledForDeletion = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys);
+
+ foreach ($this->productCategorysScheduledForDeletion as $productCategoryRemoved) {
+ $productCategoryRemoved->setCategory(null);
+ }
+
+ $this->collProductCategorys = null;
+ foreach ($productCategorys as $productCategory) {
+ $this->addProductCategory($productCategory);
+ }
+
+ $this->collProductCategorys = $productCategorys;
+ $this->collProductCategorysPartial = false;
+ }
+
+ /**
+ * Returns the number of related ProductCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ProductCategory objects.
+ * @throws PropelException
+ */
+ public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collProductCategorysPartial && !$this->isNew();
+ if (null === $this->collProductCategorys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductCategorys) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getProductCategorys());
+ }
+ $query = ProductCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collProductCategorys);
+ }
+ }
+
+ /**
+ * Method called to associate a ProductCategory object to this object
+ * through the ProductCategory foreign key attribute.
+ *
+ * @param ProductCategory $l ProductCategory
+ * @return Category The current object (for fluent API support)
+ */
+ public function addProductCategory(ProductCategory $l)
+ {
+ if ($this->collProductCategorys === null) {
+ $this->initProductCategorys();
+ $this->collProductCategorysPartial = true;
+ }
+ if (!$this->collProductCategorys->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddProductCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ProductCategory $productCategory The productCategory object to add.
+ */
+ protected function doAddProductCategory($productCategory)
+ {
+ $this->collProductCategorys[]= $productCategory;
+ $productCategory->setCategory($this);
+ }
+
+ /**
+ * @param ProductCategory $productCategory The productCategory object to remove.
+ */
+ public function removeProductCategory($productCategory)
+ {
+ if ($this->getProductCategorys()->contains($productCategory)) {
+ $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory));
+ if (null === $this->productCategorysScheduledForDeletion) {
+ $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys;
+ $this->productCategorysScheduledForDeletion->clear();
+ }
+ $this->productCategorysScheduledForDeletion[]= $productCategory;
+ $productCategory->setCategory(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related ProductCategorys from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects
+ */
+ public function getProductCategorysJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = ProductCategoryQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getProductCategorys($query, $con);
+ }
+
+ /**
+ * Clears out the 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 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)
+ ->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 {
+ 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 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);
+ }
+
+ /**
+ * @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->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 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);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->parent = null;
+ $this->link = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ 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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CategoryPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCategoryDesc.php b/core/lib/Thelia/Model/om/BaseCategoryDesc.php
new file mode 100644
index 000000000..4b24dc079
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategoryDesc.php
@@ -0,0 +1,1375 @@
+id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->postscriptum;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CategoryDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = CategoryDescPeer::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = CategoryDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = CategoryDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = CategoryDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = CategoryDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = CategoryDescPeer::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CategoryDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CategoryDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CategoryDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->category_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->postscriptum = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = CategoryDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CategoryDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CategoryDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CategoryDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CategoryDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CategoryDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CategoryDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CategoryDescPeer::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`';
+ }
+ if ($this->isColumnModified(CategoryDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(CategoryDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(CategoryDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(CategoryDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(CategoryDescPeer::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`';
+ }
+ if ($this->isColumnModified(CategoryDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CategoryDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `category_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CATEGORY_ID`':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`POSTSCRIPTUM`':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CategoryDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCategoryId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getPostscriptum();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CategoryDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CategoryDesc'][$this->getPrimaryKey()] = true;
+ $keys = CategoryDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCategoryId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getPostscriptum(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CategoryDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCategoryId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setPostscriptum($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CategoryDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setPostscriptum($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CategoryDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CategoryDescPeer::ID)) $criteria->add(CategoryDescPeer::ID, $this->id);
+ if ($this->isColumnModified(CategoryDescPeer::CATEGORY_ID)) $criteria->add(CategoryDescPeer::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(CategoryDescPeer::LANG)) $criteria->add(CategoryDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(CategoryDescPeer::TITLE)) $criteria->add(CategoryDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(CategoryDescPeer::DESCRIPTION)) $criteria->add(CategoryDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(CategoryDescPeer::CHAPO)) $criteria->add(CategoryDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(CategoryDescPeer::POSTSCRIPTUM)) $criteria->add(CategoryDescPeer::POSTSCRIPTUM, $this->postscriptum);
+ if ($this->isColumnModified(CategoryDescPeer::CREATED_AT)) $criteria->add(CategoryDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CategoryDescPeer::UPDATED_AT)) $criteria->add(CategoryDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CategoryDescPeer::DATABASE_NAME);
+ $criteria->add(CategoryDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CategoryDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CategoryDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CategoryDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CategoryDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return CategoryDesc 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->category_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CategoryDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCategoryDescPeer.php b/core/lib/Thelia/Model/om/BaseCategoryDescPeer.php
new file mode 100644
index 000000000..eeb25a350
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategoryDescPeer.php
@@ -0,0 +1,1042 @@
+ array ('Id', 'CategoryId', 'Lang', 'Title', 'Description', 'Chapo', 'Postscriptum', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'categoryId', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CategoryDescPeer::ID, CategoryDescPeer::CATEGORY_ID, CategoryDescPeer::LANG, CategoryDescPeer::TITLE, CategoryDescPeer::DESCRIPTION, CategoryDescPeer::CHAPO, CategoryDescPeer::POSTSCRIPTUM, CategoryDescPeer::CREATED_AT, CategoryDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CATEGORY_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'category_id', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CategoryDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CategoryId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Postscriptum' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'categoryId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ BasePeer::TYPE_COLNAME => array (CategoryDescPeer::ID => 0, CategoryDescPeer::CATEGORY_ID => 1, CategoryDescPeer::LANG => 2, CategoryDescPeer::TITLE => 3, CategoryDescPeer::DESCRIPTION => 4, CategoryDescPeer::CHAPO => 5, CategoryDescPeer::POSTSCRIPTUM => 6, CategoryDescPeer::CREATED_AT => 7, CategoryDescPeer::UPDATED_AT => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CATEGORY_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'POSTSCRIPTUM' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'category_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CategoryDescPeer::getFieldNames($toType);
+ $key = isset(CategoryDescPeer::$fieldKeys[$fromType][$name]) ? CategoryDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CategoryDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CategoryDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CategoryDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CategoryDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CategoryDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CategoryDescPeer::ID);
+ $criteria->addSelectColumn(CategoryDescPeer::CATEGORY_ID);
+ $criteria->addSelectColumn(CategoryDescPeer::LANG);
+ $criteria->addSelectColumn(CategoryDescPeer::TITLE);
+ $criteria->addSelectColumn(CategoryDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(CategoryDescPeer::CHAPO);
+ $criteria->addSelectColumn(CategoryDescPeer::POSTSCRIPTUM);
+ $criteria->addSelectColumn(CategoryDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(CategoryDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CategoryDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CategoryDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CategoryDescPeer::populateObjects(CategoryDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CategoryDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CategoryDesc $obj A CategoryDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CategoryDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CategoryDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CategoryDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CategoryDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CategoryDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CategoryDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CategoryDescPeer::$instances[$key])) {
+ return CategoryDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CategoryDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to category_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CategoryDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CategoryDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CategoryDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CategoryDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CategoryDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CategoryDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CategoryDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CategoryDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CategoryDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CategoryDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CategoryDescPeer::DATABASE_NAME)->getTable(CategoryDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCategoryDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCategoryDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CategoryDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CategoryDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CategoryDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or CategoryDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CategoryDesc object
+ }
+
+ if ($criteria->containsKey(CategoryDescPeer::ID) && $criteria->keyContainsValue(CategoryDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a CategoryDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or CategoryDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CategoryDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CategoryDescPeer::ID);
+ $value = $criteria->remove(CategoryDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CategoryDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CategoryDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is CategoryDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the category_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ CategoryDescPeer::clearInstancePool();
+ CategoryDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CategoryDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CategoryDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(CategoryDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CategoryDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CategoryDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CategoryDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CategoryDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CategoryDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CategoryDescPeer::DATABASE_NAME, CategoryDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CategoryDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CategoryDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CategoryDescPeer::DATABASE_NAME);
+ $criteria->add(CategoryDescPeer::ID, $pk);
+
+ $v = CategoryDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return CategoryDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CategoryDescPeer::DATABASE_NAME);
+ $criteria->add(CategoryDescPeer::ID, $pks, Criteria::IN);
+ $objs = CategoryDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCategoryDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCategoryDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php b/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php
new file mode 100644
index 000000000..7472e3527
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php
@@ -0,0 +1,646 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CategoryDesc|CategoryDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CategoryDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CategoryDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CATEGORY_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM`, `CREATED_AT`, `UPDATED_AT` FROM `category_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new CategoryDesc();
+ $obj->hydrate($row);
+ CategoryDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CategoryDesc|CategoryDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|CategoryDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CategoryDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CategoryDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(CategoryDescPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(CategoryDescPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CategoryDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CategoryDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CategoryDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CategoryDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 CategoryDescQuery 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(CategoryDescPeer::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CategoryDescPeer::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 CategoryDescQuery 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
+ *
+ * @param CategoryDesc $categoryDesc Object to remove from the list of results
+ *
+ * @return CategoryDescQuery The current query, for fluid interface
+ */
+ public function prune($categoryDesc = null)
+ {
+ if ($categoryDesc) {
+ $this->addUsingAlias(CategoryDescPeer::ID, $categoryDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCategoryPeer.php b/core/lib/Thelia/Model/om/BaseCategoryPeer.php
new file mode 100644
index 000000000..cda44319d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategoryPeer.php
@@ -0,0 +1,825 @@
+ array ('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CategoryPeer::ID, CategoryPeer::PARENT, CategoryPeer::LINK, CategoryPeer::VISIBLE, CategoryPeer::POSITION, CategoryPeer::CREATED_AT, CategoryPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (CategoryPeer::ID => 0, CategoryPeer::PARENT => 1, CategoryPeer::LINK => 2, CategoryPeer::VISIBLE => 3, CategoryPeer::POSITION => 4, CategoryPeer::CREATED_AT => 5, CategoryPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CategoryPeer::getFieldNames($toType);
+ $key = isset(CategoryPeer::$fieldKeys[$fromType][$name]) ? CategoryPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CategoryPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CategoryPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CategoryPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CategoryPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CategoryPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CategoryPeer::ID);
+ $criteria->addSelectColumn(CategoryPeer::PARENT);
+ $criteria->addSelectColumn(CategoryPeer::LINK);
+ $criteria->addSelectColumn(CategoryPeer::VISIBLE);
+ $criteria->addSelectColumn(CategoryPeer::POSITION);
+ $criteria->addSelectColumn(CategoryPeer::CREATED_AT);
+ $criteria->addSelectColumn(CategoryPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.LINK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CategoryPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Category
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CategoryPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CategoryPeer::populateObjects(CategoryPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CategoryPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Category $obj A Category object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CategoryPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Category object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Category) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Category object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CategoryPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Category Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CategoryPeer::$instances[$key])) {
+ return CategoryPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CategoryPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to category
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CategoryPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CategoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CategoryPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Category object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CategoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CategoryPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CategoryPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CategoryPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CategoryPeer::DATABASE_NAME)->getTable(CategoryPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCategoryPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCategoryPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CategoryTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CategoryPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Category or Criteria object.
+ *
+ * @param mixed $values Criteria or Category object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Category object
+ }
+
+ if ($criteria->containsKey(CategoryPeer::ID) && $criteria->keyContainsValue(CategoryPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Category or Criteria object.
+ *
+ * @param mixed $values Criteria or Category object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CategoryPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CategoryPeer::ID);
+ $value = $criteria->remove(CategoryPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CategoryPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CategoryPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Category object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CategoryPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the category table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(CategoryPeer::TABLE_NAME, $con, CategoryPeer::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
+ // instances get re-added by the select statement contained therein).
+ CategoryPeer::clearInstancePool();
+ CategoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Category or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Category object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ CategoryPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Category) { // it's a model object
+ // invalidate the cache for this single object
+ CategoryPeer::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(CategoryPeer::DATABASE_NAME);
+ $criteria->add(CategoryPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CategoryPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CategoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Category object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Category $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CategoryPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CategoryPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CategoryPeer::DATABASE_NAME, CategoryPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Category
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CategoryPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
+ $criteria->add(CategoryPeer::ID, $pk);
+
+ $v = CategoryPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Category[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
+ $criteria->add(CategoryPeer::ID, $pks, Criteria::IN);
+ $objs = CategoryPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCategoryPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCategoryPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCategoryQuery.php b/core/lib/Thelia/Model/om/BaseCategoryQuery.php
new file mode 100644
index 000000000..fdd8e09ee
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategoryQuery.php
@@ -0,0 +1,1153 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Category|Category[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CategoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Category A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `category` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Category();
+ $obj->hydrate($row);
+ CategoryPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Category|Category[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Category[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CategoryPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CategoryPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CategoryPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent column
+ *
+ * Example usage:
+ *
+ * $query->filterByParent(1234); // WHERE parent = 1234
+ * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
+ * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
+ *
+ *
+ * @param mixed $parent The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterByParent($parent = null, $comparison = null)
+ {
+ if (is_array($parent)) {
+ $useMinMax = false;
+ if (isset($parent['min'])) {
+ $this->addUsingAlias(CategoryPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(CategoryPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::PARENT, $parent, $comparison);
+ }
+
+ /**
+ * Filter the query on the link column
+ *
+ * Example usage:
+ *
+ * $query->filterByLink('fooValue'); // WHERE link = 'fooValue'
+ * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%'
+ *
+ *
+ * @param string $link The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterByLink($link = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($link)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $link)) {
+ $link = str_replace('*', '%', $link);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::LINK, $link, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(CategoryPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(CategoryPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(CategoryPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(CategoryPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related AttributeCategory object
+ *
+ * @param AttributeCategory|PropelObjectCollection $attributeCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeCategory($attributeCategory, $comparison = null)
+ {
+ if ($attributeCategory instanceof AttributeCategory) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $attributeCategory->getCategoryId(), $comparison);
+ } elseif ($attributeCategory instanceof PropelObjectCollection) {
+ return $this
+ ->useAttributeCategoryQuery()
+ ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCategory relation AttributeCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related CategoryDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCategoryDesc($categoryDesc, $comparison = null)
+ {
+ if ($categoryDesc instanceof CategoryDesc) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $categoryDesc->getCategoryId(), $comparison);
+ } elseif ($categoryDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useCategoryDescQuery()
+ ->filterByPrimaryKeys($categoryDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCategoryDesc() only accepts arguments of type CategoryDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CategoryDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function joinCategoryDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CategoryDesc');
+
+ // 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, 'CategoryDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CategoryDesc relation CategoryDesc 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\CategoryDescQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCategoryDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CategoryDesc', '\Thelia\Model\CategoryDescQuery');
+ }
+
+ /**
+ * Filter the query by a related ContentAssoc object
+ *
+ * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContentAssoc($contentAssoc, $comparison = null)
+ {
+ if ($contentAssoc instanceof ContentAssoc) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $contentAssoc->getCategoryId(), $comparison);
+ } elseif ($contentAssoc instanceof PropelObjectCollection) {
+ return $this
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentAssoc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentAssoc');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentAssoc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentAssoc relation ContentAssoc object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
+ */
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContentAssoc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery');
+ }
+
+ /**
+ * Filter the query by a related Document object
+ *
+ * @param Document|PropelObjectCollection $document the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof Document) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $document->getCategoryId(), $comparison);
+ } elseif ($document instanceof PropelObjectCollection) {
+ return $this
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Filter the query by a related FeatureCategory object
+ *
+ * @param FeatureCategory|PropelObjectCollection $featureCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFeatureCategory($featureCategory, $comparison = null)
+ {
+ if ($featureCategory instanceof FeatureCategory) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $featureCategory->getCategoryId(), $comparison);
+ } elseif ($featureCategory instanceof PropelObjectCollection) {
+ return $this
+ ->useFeatureCategoryQuery()
+ ->filterByPrimaryKeys($featureCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureCategory relation FeatureCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related Image object
+ *
+ * @param Image|PropelObjectCollection $image the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof Image) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $image->getCategoryId(), $comparison);
+ } elseif ($image instanceof PropelObjectCollection) {
+ return $this
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Filter the query by a related ProductCategory object
+ *
+ * @param ProductCategory|PropelObjectCollection $productCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByProductCategory($productCategory, $comparison = null)
+ {
+ if ($productCategory instanceof ProductCategory) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $productCategory->getCategoryId(), $comparison);
+ } elseif ($productCategory instanceof PropelObjectCollection) {
+ return $this
+ ->useProductCategoryQuery()
+ ->filterByPrimaryKeys($productCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductCategory relation ProductCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related Rewriting object
+ *
+ * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByRewriting($rewriting, $comparison = null)
+ {
+ if ($rewriting instanceof Rewriting) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $rewriting->getCategoryId(), $comparison);
+ } elseif ($rewriting instanceof PropelObjectCollection) {
+ return $this
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Rewriting relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Rewriting');
+
+ // 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, 'Rewriting');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Rewriting relation Rewriting 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\RewritingQuery A secondary query class using the current class as primary query
+ */
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinRewriting($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Category $category Object to remove from the list of results
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ */
+ public function prune($category = null)
+ {
+ if ($category) {
+ $this->addUsingAlias(CategoryPeer::ID, $category->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCombination.php b/core/lib/Thelia/Model/om/BaseCombination.php
new file mode 100644
index 000000000..c692e5cdc
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCombination.php
@@ -0,0 +1,1635 @@
+id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+ return $this->ref;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Combination The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CombinationPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return Combination The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = CombinationPeer::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Combination The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CombinationPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Combination The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CombinationPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->ref = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = CombinationPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Combination object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CombinationPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAttributeCombinations = null;
+
+ $this->collStocks = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CombinationQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CombinationPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CombinationPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CombinationPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CombinationPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CombinationPeer::REF)) {
+ $modifiedColumns[':p' . $index++] = '`REF`';
+ }
+ if ($this->isColumnModified(CombinationPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CombinationPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `combination` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`REF`':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getRef();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Combination'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Combination'][$this->getPrimaryKey()] = true;
+ $keys = CombinationPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRef(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collStocks) {
+ $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setRef($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CombinationPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CombinationPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CombinationPeer::ID)) $criteria->add(CombinationPeer::ID, $this->id);
+ if ($this->isColumnModified(CombinationPeer::REF)) $criteria->add(CombinationPeer::REF, $this->ref);
+ if ($this->isColumnModified(CombinationPeer::CREATED_AT)) $criteria->add(CombinationPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CombinationPeer::UPDATED_AT)) $criteria->add(CombinationPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CombinationPeer::DATABASE_NAME);
+ $criteria->add(CombinationPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Combination (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ foreach ($this->getStocks() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addStock($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Combination Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CombinationPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CombinationPeer();
+ }
+
+ 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.
+ *
+ * @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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to add.
+ */
+ protected function doAddAttributeCombination($attributeCombination)
+ {
+ $this->collAttributeCombinations[]= $attributeCombination;
+ $attributeCombination->setCombination($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->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.
+ *
+ * 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 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)
+ ->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 {
+ 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 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);
+ }
+
+ /**
+ * @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->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 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);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->ref = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ if ($this->collAttributeCombinations instanceof PropelCollection) {
+ $this->collAttributeCombinations->clearIterator();
+ }
+ $this->collAttributeCombinations = null;
+ if ($this->collStocks instanceof PropelCollection) {
+ $this->collStocks->clearIterator();
+ }
+ $this->collStocks = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CombinationPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCombinationPeer.php b/core/lib/Thelia/Model/om/BaseCombinationPeer.php
new file mode 100644
index 000000000..19c0b38ba
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCombinationPeer.php
@@ -0,0 +1,786 @@
+ array ('Id', 'Ref', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'ref', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CombinationPeer::ID, CombinationPeer::REF, CombinationPeer::CREATED_AT, CombinationPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'REF', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'ref', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CombinationPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Ref' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'ref' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ BasePeer::TYPE_COLNAME => array (CombinationPeer::ID => 0, CombinationPeer::REF => 1, CombinationPeer::CREATED_AT => 2, CombinationPeer::UPDATED_AT => 3, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'REF' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'ref' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CombinationPeer::getFieldNames($toType);
+ $key = isset(CombinationPeer::$fieldKeys[$fromType][$name]) ? CombinationPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CombinationPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CombinationPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CombinationPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CombinationPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CombinationPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CombinationPeer::ID);
+ $criteria->addSelectColumn(CombinationPeer::REF);
+ $criteria->addSelectColumn(CombinationPeer::CREATED_AT);
+ $criteria->addSelectColumn(CombinationPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CombinationPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Combination
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CombinationPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CombinationPeer::populateObjects(CombinationPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CombinationPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CombinationPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Combination $obj A Combination object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CombinationPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Combination object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Combination) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Combination object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CombinationPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Combination Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CombinationPeer::$instances[$key])) {
+ return CombinationPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CombinationPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to combination
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CombinationPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CombinationPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CombinationPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CombinationPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Combination object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CombinationPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CombinationPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CombinationPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CombinationPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CombinationPeer::DATABASE_NAME)->getTable(CombinationPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCombinationPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCombinationPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CombinationTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CombinationPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Combination or Criteria object.
+ *
+ * @param mixed $values Criteria or Combination object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Combination object
+ }
+
+ if ($criteria->containsKey(CombinationPeer::ID) && $criteria->keyContainsValue(CombinationPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CombinationPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CombinationPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Combination or Criteria object.
+ *
+ * @param mixed $values Criteria or Combination object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CombinationPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CombinationPeer::ID);
+ $value = $criteria->remove(CombinationPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CombinationPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CombinationPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Combination object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CombinationPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the combination table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(CombinationPeer::TABLE_NAME, $con, CombinationPeer::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
+ // instances get re-added by the select statement contained therein).
+ CombinationPeer::clearInstancePool();
+ CombinationPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Combination or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Combination object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ CombinationPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Combination) { // it's a model object
+ // invalidate the cache for this single object
+ CombinationPeer::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(CombinationPeer::DATABASE_NAME);
+ $criteria->add(CombinationPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CombinationPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CombinationPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CombinationPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Combination object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Combination $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CombinationPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CombinationPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CombinationPeer::DATABASE_NAME, CombinationPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Combination
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CombinationPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CombinationPeer::DATABASE_NAME);
+ $criteria->add(CombinationPeer::ID, $pk);
+
+ $v = CombinationPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Combination[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CombinationPeer::DATABASE_NAME);
+ $criteria->add(CombinationPeer::ID, $pks, Criteria::IN);
+ $objs = CombinationPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCombinationPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCombinationPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCombinationQuery.php b/core/lib/Thelia/Model/om/BaseCombinationQuery.php
new file mode 100644
index 000000000..a1e4e3d5f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCombinationQuery.php
@@ -0,0 +1,544 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Combination|Combination[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CombinationPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Combination A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `REF`, `CREATED_AT`, `UPDATED_AT` FROM `combination` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Combination();
+ $obj->hydrate($row);
+ CombinationPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Combination|Combination[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Combination[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CombinationPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CombinationPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CombinationPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CombinationPeer::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CombinationPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CombinationPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CombinationPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CombinationPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CombinationPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CombinationPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related AttributeCombination object
+ *
+ * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAttributeCombination($attributeCombination, $comparison = null)
+ {
+ if ($attributeCombination instanceof AttributeCombination) {
+ return $this
+ ->addUsingAlias(CombinationPeer::ID, $attributeCombination->getCombinationId(), $comparison);
+ } elseif ($attributeCombination instanceof PropelObjectCollection) {
+ return $this
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCombination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCombination');
+
+ // 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, 'AttributeCombination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCombination relation AttributeCombination 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\AttributeCombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery');
+ }
+
+ /**
+ * Filter the query by a related Stock object
+ *
+ * @param Stock|PropelObjectCollection $stock the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByStock($stock, $comparison = null)
+ {
+ if ($stock instanceof Stock) {
+ return $this
+ ->addUsingAlias(CombinationPeer::ID, $stock->getCombinationId(), $comparison);
+ } elseif ($stock instanceof PropelObjectCollection) {
+ return $this
+ ->useStockQuery()
+ ->filterByPrimaryKeys($stock->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Stock relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function joinStock($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Stock');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Stock');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Stock relation Stock object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query
+ */
+ public function useStockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinStock($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Combination $combination Object to remove from the list of results
+ *
+ * @return CombinationQuery The current query, for fluid interface
+ */
+ public function prune($combination = null)
+ {
+ if ($combination) {
+ $this->addUsingAlias(CombinationPeer::ID, $combination->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseConfig.php b/core/lib/Thelia/Model/om/BaseConfig.php
new file mode 100644
index 000000000..5bb82ad08
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseConfig.php
@@ -0,0 +1,1488 @@
+secure = 1;
+ $this->hidden = 1;
+ }
+
+ /**
+ * Initializes internal state of BaseConfig object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Get the [name] column value.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Get the [secure] column value.
+ *
+ * @return int
+ */
+ public function getSecure()
+ {
+ return $this->secure;
+ }
+
+ /**
+ * Get the [hidden] column value.
+ *
+ * @return int
+ */
+ public function getHidden()
+ {
+ return $this->hidden;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Config The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ConfigPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [name] column.
+ *
+ * @param string $v new value
+ * @return Config The current object (for fluent API support)
+ */
+ public function setName($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->name !== $v) {
+ $this->name = $v;
+ $this->modifiedColumns[] = ConfigPeer::NAME;
+ }
+
+
+ return $this;
+ } // setName()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param string $v new value
+ * @return Config The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = ConfigPeer::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Set the value of [secure] column.
+ *
+ * @param int $v new value
+ * @return Config The current object (for fluent API support)
+ */
+ public function setSecure($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->secure !== $v) {
+ $this->secure = $v;
+ $this->modifiedColumns[] = ConfigPeer::SECURE;
+ }
+
+
+ return $this;
+ } // setSecure()
+
+ /**
+ * Set the value of [hidden] column.
+ *
+ * @param int $v new value
+ * @return Config The current object (for fluent API support)
+ */
+ public function setHidden($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->hidden !== $v) {
+ $this->hidden = $v;
+ $this->modifiedColumns[] = ConfigPeer::HIDDEN;
+ }
+
+
+ return $this;
+ } // setHidden()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Config The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ConfigPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Config The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ConfigPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->secure !== 1) {
+ return false;
+ }
+
+ if ($this->hidden !== 1) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->value = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->secure = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->hidden = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = ConfigPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Config object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ConfigPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collConfigDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ConfigQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ConfigPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ConfigPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ConfigPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ConfigPeer::NAME)) {
+ $modifiedColumns[':p' . $index++] = '`NAME`';
+ }
+ if ($this->isColumnModified(ConfigPeer::VALUE)) {
+ $modifiedColumns[':p' . $index++] = '`VALUE`';
+ }
+ if ($this->isColumnModified(ConfigPeer::SECURE)) {
+ $modifiedColumns[':p' . $index++] = '`SECURE`';
+ }
+ if ($this->isColumnModified(ConfigPeer::HIDDEN)) {
+ $modifiedColumns[':p' . $index++] = '`HIDDEN`';
+ }
+ if ($this->isColumnModified(ConfigPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `config` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`NAME`':
+ $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
+ break;
+ case '`VALUE`':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case '`SECURE`':
+ $stmt->bindValue($identifier, $this->secure, PDO::PARAM_INT);
+ break;
+ case '`HIDDEN`':
+ $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getName();
+ break;
+ case 2:
+ return $this->getValue();
+ break;
+ case 3:
+ return $this->getSecure();
+ break;
+ case 4:
+ return $this->getHidden();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Config'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Config'][$this->getPrimaryKey()] = true;
+ $keys = ConfigPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getName(),
+ $keys[2] => $this->getValue(),
+ $keys[3] => $this->getSecure(),
+ $keys[4] => $this->getHidden(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collConfigDescs) {
+ $result['ConfigDescs'] = $this->collConfigDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setName($value);
+ break;
+ case 2:
+ $this->setValue($value);
+ break;
+ case 3:
+ $this->setSecure($value);
+ break;
+ case 4:
+ $this->setHidden($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ConfigPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setSecure($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setHidden($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ConfigPeer::ID)) $criteria->add(ConfigPeer::ID, $this->id);
+ if ($this->isColumnModified(ConfigPeer::NAME)) $criteria->add(ConfigPeer::NAME, $this->name);
+ if ($this->isColumnModified(ConfigPeer::VALUE)) $criteria->add(ConfigPeer::VALUE, $this->value);
+ if ($this->isColumnModified(ConfigPeer::SECURE)) $criteria->add(ConfigPeer::SECURE, $this->secure);
+ if ($this->isColumnModified(ConfigPeer::HIDDEN)) $criteria->add(ConfigPeer::HIDDEN, $this->hidden);
+ if ($this->isColumnModified(ConfigPeer::CREATED_AT)) $criteria->add(ConfigPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) $criteria->add(ConfigPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
+ $criteria->add(ConfigPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Config (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setName($this->getName());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setSecure($this->getSecure());
+ $copyObj->setHidden($this->getHidden());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Config Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ConfigPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ConfigPeer();
+ }
+
+ 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.
+ *
+ * @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 getConfigDescs($criteria = null, PropelPDO $con = 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 {
+ return count($this->collConfigDescs);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * @param ConfigDesc $configDesc The configDesc object to remove.
+ */
+ public function removeConfigDesc($configDesc)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->name = null;
+ $this->value = null;
+ $this->secure = null;
+ $this->hidden = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collConfigDescs) {
+ foreach ($this->collConfigDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collConfigDescs instanceof PropelCollection) {
+ $this->collConfigDescs->clearIterator();
+ }
+ $this->collConfigDescs = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ConfigPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseConfigDesc.php b/core/lib/Thelia/Model/om/BaseConfigDesc.php
new file mode 100644
index 000000000..10b5dcb67
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseConfigDesc.php
@@ -0,0 +1,1320 @@
+id;
+ }
+
+ /**
+ * Get the [config_id] column value.
+ *
+ * @return int
+ */
+ public function getConfigId()
+ {
+ return $this->config_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ConfigDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ConfigDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [config_id] column.
+ *
+ * @param int $v new value
+ * @return ConfigDesc The current object (for fluent API support)
+ */
+ public function setConfigId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->config_id !== $v) {
+ $this->config_id = $v;
+ $this->modifiedColumns[] = ConfigDescPeer::CONFIG_ID;
+ }
+
+ if ($this->aConfig !== null && $this->aConfig->getId() !== $v) {
+ $this->aConfig = null;
+ }
+
+
+ return $this;
+ } // setConfigId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return ConfigDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = ConfigDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return ConfigDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ConfigDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return ConfigDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ConfigDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return ConfigDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ConfigDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ConfigDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ConfigDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ConfigDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ConfigDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->config_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = ConfigDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ConfigDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aConfig !== null && $this->config_id !== $this->aConfig->getId()) {
+ $this->aConfig = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ConfigDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aConfig = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ConfigDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ConfigDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ConfigDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ConfigDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ConfigDescPeer::CONFIG_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CONFIG_ID`';
+ }
+ if ($this->isColumnModified(ConfigDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(ConfigDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(ConfigDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(ConfigDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(ConfigDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ConfigDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `config_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CONFIG_ID`':
+ $stmt->bindValue($identifier, $this->config_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ConfigDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getConfigId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ConfigDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ConfigDesc'][$this->getPrimaryKey()] = true;
+ $keys = ConfigDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getConfigId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aConfig) {
+ $result['Config'] = $this->aConfig->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ConfigDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setConfigId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ConfigDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setConfigId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ConfigDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ConfigDescPeer::ID)) $criteria->add(ConfigDescPeer::ID, $this->id);
+ if ($this->isColumnModified(ConfigDescPeer::CONFIG_ID)) $criteria->add(ConfigDescPeer::CONFIG_ID, $this->config_id);
+ if ($this->isColumnModified(ConfigDescPeer::LANG)) $criteria->add(ConfigDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(ConfigDescPeer::TITLE)) $criteria->add(ConfigDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(ConfigDescPeer::DESCRIPTION)) $criteria->add(ConfigDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ConfigDescPeer::CHAPO)) $criteria->add(ConfigDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ConfigDescPeer::CREATED_AT)) $criteria->add(ConfigDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ConfigDescPeer::UPDATED_AT)) $criteria->add(ConfigDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ConfigDescPeer::DATABASE_NAME);
+ $criteria->add(ConfigDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ConfigDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setConfigId($this->getConfigId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ConfigDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ConfigDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ConfigDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Config object.
+ *
+ * @param Config $v
+ * @return ConfigDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setConfig(Config $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->config_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aConfig = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ConfigDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseConfigDescPeer.php b/core/lib/Thelia/Model/om/BaseConfigDescPeer.php
new file mode 100644
index 000000000..87950542f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseConfigDescPeer.php
@@ -0,0 +1,1037 @@
+ array ('Id', 'ConfigId', 'Lang', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'configId', 'lang', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ConfigDescPeer::ID, ConfigDescPeer::CONFIG_ID, ConfigDescPeer::LANG, ConfigDescPeer::TITLE, ConfigDescPeer::DESCRIPTION, ConfigDescPeer::CHAPO, ConfigDescPeer::CREATED_AT, ConfigDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CONFIG_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'config_id', 'lang', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ConfigDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ConfigId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'configId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (ConfigDescPeer::ID => 0, ConfigDescPeer::CONFIG_ID => 1, ConfigDescPeer::LANG => 2, ConfigDescPeer::TITLE => 3, ConfigDescPeer::DESCRIPTION => 4, ConfigDescPeer::CHAPO => 5, ConfigDescPeer::CREATED_AT => 6, ConfigDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CONFIG_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'config_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ConfigDescPeer::getFieldNames($toType);
+ $key = isset(ConfigDescPeer::$fieldKeys[$fromType][$name]) ? ConfigDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ConfigDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ConfigDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ConfigDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ConfigDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ConfigDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ConfigDescPeer::ID);
+ $criteria->addSelectColumn(ConfigDescPeer::CONFIG_ID);
+ $criteria->addSelectColumn(ConfigDescPeer::LANG);
+ $criteria->addSelectColumn(ConfigDescPeer::TITLE);
+ $criteria->addSelectColumn(ConfigDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(ConfigDescPeer::CHAPO);
+ $criteria->addSelectColumn(ConfigDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(ConfigDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CONFIG_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ConfigDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ConfigDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ConfigDescPeer::populateObjects(ConfigDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ConfigDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ConfigDesc $obj A ConfigDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ConfigDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ConfigDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ConfigDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ConfigDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ConfigDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ConfigDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ConfigDescPeer::$instances[$key])) {
+ return ConfigDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ConfigDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to config_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ConfigDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ConfigDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ConfigDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ConfigDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ConfigDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ConfigDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ConfigDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ConfigDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ConfigDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ConfigDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ConfigDescPeer::DATABASE_NAME)->getTable(ConfigDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseConfigDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseConfigDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ConfigDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ConfigDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ConfigDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ConfigDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ConfigDesc object
+ }
+
+ if ($criteria->containsKey(ConfigDescPeer::ID) && $criteria->keyContainsValue(ConfigDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConfigDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ConfigDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ConfigDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ConfigDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ConfigDescPeer::ID);
+ $value = $criteria->remove(ConfigDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ConfigDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ConfigDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ConfigDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the config_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ConfigDescPeer::clearInstancePool();
+ ConfigDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ConfigDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ConfigDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ConfigDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ConfigDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ConfigDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ConfigDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ConfigDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ConfigDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ConfigDescPeer::DATABASE_NAME, ConfigDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return ConfigDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ConfigDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ConfigDescPeer::DATABASE_NAME);
+ $criteria->add(ConfigDescPeer::ID, $pk);
+
+ $v = ConfigDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return ConfigDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ConfigDescPeer::DATABASE_NAME);
+ $criteria->add(ConfigDescPeer::ID, $pks, Criteria::IN);
+ $objs = ConfigDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseConfigDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseConfigDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseConfigDescQuery.php b/core/lib/Thelia/Model/om/BaseConfigDescQuery.php
new file mode 100644
index 000000000..cf63e9603
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseConfigDescQuery.php
@@ -0,0 +1,613 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ConfigDesc|ConfigDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ConfigDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ConfigDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CONFIG_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `config_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ConfigDesc();
+ $obj->hydrate($row);
+ ConfigDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ConfigDesc|ConfigDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ConfigDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ConfigDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ConfigDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ConfigDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the config_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByConfigId(1234); // WHERE config_id = 1234
+ * $query->filterByConfigId(array(12, 34)); // WHERE config_id IN (12, 34)
+ * $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.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByConfigId($configId = null, $comparison = null)
+ {
+ if (is_array($configId)) {
+ $useMinMax = false;
+ if (isset($configId['min'])) {
+ $this->addUsingAlias(ConfigDescPeer::CONFIG_ID, $configId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($configId['max'])) {
+ $this->addUsingAlias(ConfigDescPeer::CONFIG_ID, $configId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigDescPeer::CONFIG_ID, $configId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ConfigDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ConfigDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ConfigDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ConfigDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Config object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByConfig($config, $comparison = null)
+ {
+ if ($config instanceof Config) {
+ return $this
+ ->addUsingAlias(ConfigDescPeer::CONFIG_ID, $config->getId(), $comparison);
+ } elseif ($config instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ConfigDescPeer::CONFIG_ID, $config->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByConfig() only accepts arguments of type Config or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Config relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function joinConfig($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Config');
+
+ // 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, 'Config');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Config relation Config 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\ConfigQuery A secondary query class using the current class as primary query
+ */
+ public function useConfigQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinConfig($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Config', '\Thelia\Model\ConfigQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ConfigDesc $configDesc Object to remove from the list of results
+ *
+ * @return ConfigDescQuery The current query, for fluid interface
+ */
+ public function prune($configDesc = null)
+ {
+ if ($configDesc) {
+ $this->addUsingAlias(ConfigDescPeer::ID, $configDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseConfigPeer.php b/core/lib/Thelia/Model/om/BaseConfigPeer.php
new file mode 100644
index 000000000..fa800aedb
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseConfigPeer.php
@@ -0,0 +1,797 @@
+ array ('Id', 'Name', 'Value', 'Secure', 'Hidden', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'value', 'secure', 'hidden', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ConfigPeer::ID, ConfigPeer::NAME, ConfigPeer::VALUE, ConfigPeer::SECURE, ConfigPeer::HIDDEN, ConfigPeer::CREATED_AT, ConfigPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'VALUE', 'SECURE', 'HIDDEN', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'value', 'secure', 'hidden', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ConfigPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Value' => 2, 'Secure' => 3, 'Hidden' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'value' => 2, 'secure' => 3, 'hidden' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (ConfigPeer::ID => 0, ConfigPeer::NAME => 1, ConfigPeer::VALUE => 2, ConfigPeer::SECURE => 3, ConfigPeer::HIDDEN => 4, ConfigPeer::CREATED_AT => 5, ConfigPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'VALUE' => 2, 'SECURE' => 3, 'HIDDEN' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'value' => 2, 'secure' => 3, 'hidden' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ConfigPeer::getFieldNames($toType);
+ $key = isset(ConfigPeer::$fieldKeys[$fromType][$name]) ? ConfigPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ConfigPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ConfigPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ConfigPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ConfigPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ConfigPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ConfigPeer::ID);
+ $criteria->addSelectColumn(ConfigPeer::NAME);
+ $criteria->addSelectColumn(ConfigPeer::VALUE);
+ $criteria->addSelectColumn(ConfigPeer::SECURE);
+ $criteria->addSelectColumn(ConfigPeer::HIDDEN);
+ $criteria->addSelectColumn(ConfigPeer::CREATED_AT);
+ $criteria->addSelectColumn(ConfigPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.NAME');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.SECURE');
+ $criteria->addSelectColumn($alias . '.HIDDEN');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ConfigPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Config
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ConfigPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ConfigPeer::populateObjects(ConfigPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ConfigPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Config $obj A Config object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ConfigPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Config object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Config) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Config object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ConfigPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Config Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ConfigPeer::$instances[$key])) {
+ return ConfigPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ConfigPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to config
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ConfigPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ConfigPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ConfigPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ConfigPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Config object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ConfigPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ConfigPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ConfigPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ConfigPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ConfigPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ConfigPeer::DATABASE_NAME)->getTable(ConfigPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseConfigPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseConfigPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ConfigTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ConfigPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Config or Criteria object.
+ *
+ * @param mixed $values Criteria or Config object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Config object
+ }
+
+ if ($criteria->containsKey(ConfigPeer::ID) && $criteria->keyContainsValue(ConfigPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConfigPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Config or Criteria object.
+ *
+ * @param mixed $values Criteria or Config object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ConfigPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ConfigPeer::ID);
+ $value = $criteria->remove(ConfigPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ConfigPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ConfigPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Config object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ConfigPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the config table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(ConfigPeer::TABLE_NAME, $con, ConfigPeer::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
+ // instances get re-added by the select statement contained therein).
+ ConfigPeer::clearInstancePool();
+ ConfigPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Config or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Config object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ ConfigPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Config) { // it's a model object
+ // invalidate the cache for this single object
+ ConfigPeer::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(ConfigPeer::DATABASE_NAME);
+ $criteria->add(ConfigPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ConfigPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ConfigPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Config object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Config $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ConfigPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ConfigPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ConfigPeer::DATABASE_NAME, ConfigPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Config
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ConfigPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
+ $criteria->add(ConfigPeer::ID, $pk);
+
+ $v = ConfigPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Config[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
+ $criteria->add(ConfigPeer::ID, $pks, Criteria::IN);
+ $objs = ConfigPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseConfigPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseConfigPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseConfigQuery.php b/core/lib/Thelia/Model/om/BaseConfigQuery.php
new file mode 100644
index 000000000..a4090b85e
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseConfigQuery.php
@@ -0,0 +1,588 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Config|Config[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ConfigPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Config A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `NAME`, `VALUE`, `SECURE`, `HIDDEN`, `CREATED_AT`, `UPDATED_AT` FROM `config` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Config();
+ $obj->hydrate($row);
+ ConfigPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Config|Config[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Config[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ConfigPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ConfigPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ConfigPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the name column
+ *
+ * Example usage:
+ *
+ * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
+ * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
+ *
+ *
+ * @param string $name The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterByName($name = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($name)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $name)) {
+ $name = str_replace('*', '%', $name);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigPeer::NAME, $name, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue('fooValue'); // WHERE value = 'fooValue'
+ * $query->filterByValue('%fooValue%'); // WHERE value LIKE '%fooValue%'
+ *
+ *
+ * @param string $value The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($value)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $value)) {
+ $value = str_replace('*', '%', $value);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigPeer::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the secure column
+ *
+ * Example usage:
+ *
+ * $query->filterBySecure(1234); // WHERE secure = 1234
+ * $query->filterBySecure(array(12, 34)); // WHERE secure IN (12, 34)
+ * $query->filterBySecure(array('min' => 12)); // WHERE secure > 12
+ *
+ *
+ * @param mixed $secure The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterBySecure($secure = null, $comparison = null)
+ {
+ if (is_array($secure)) {
+ $useMinMax = false;
+ if (isset($secure['min'])) {
+ $this->addUsingAlias(ConfigPeer::SECURE, $secure['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($secure['max'])) {
+ $this->addUsingAlias(ConfigPeer::SECURE, $secure['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigPeer::SECURE, $secure, $comparison);
+ }
+
+ /**
+ * Filter the query on the hidden column
+ *
+ * Example usage:
+ *
+ * $query->filterByHidden(1234); // WHERE hidden = 1234
+ * $query->filterByHidden(array(12, 34)); // WHERE hidden IN (12, 34)
+ * $query->filterByHidden(array('min' => 12)); // WHERE hidden > 12
+ *
+ *
+ * @param mixed $hidden The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterByHidden($hidden = null, $comparison = null)
+ {
+ if (is_array($hidden)) {
+ $useMinMax = false;
+ if (isset($hidden['min'])) {
+ $this->addUsingAlias(ConfigPeer::HIDDEN, $hidden['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($hidden['max'])) {
+ $this->addUsingAlias(ConfigPeer::HIDDEN, $hidden['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigPeer::HIDDEN, $hidden, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ConfigPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ConfigPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ConfigPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ConfigPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related ConfigDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByConfigDesc($configDesc, $comparison = null)
+ {
+ if ($configDesc instanceof ConfigDesc) {
+ return $this
+ ->addUsingAlias(ConfigPeer::ID, $configDesc->getConfigId(), $comparison);
+ } elseif ($configDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useConfigDescQuery()
+ ->filterByPrimaryKeys($configDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByConfigDesc() only accepts arguments of type ConfigDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ConfigDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function joinConfigDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ConfigDesc');
+
+ // 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, 'ConfigDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ConfigDesc relation ConfigDesc 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\ConfigDescQuery A secondary query class using the current class as primary query
+ */
+ public function useConfigDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinConfigDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ConfigDesc', '\Thelia\Model\ConfigDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Config $config Object to remove from the list of results
+ *
+ * @return ConfigQuery The current query, for fluid interface
+ */
+ public function prune($config = null)
+ {
+ if ($config) {
+ $this->addUsingAlias(ConfigPeer::ID, $config->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContent.php b/core/lib/Thelia/Model/om/BaseContent.php
new file mode 100644
index 000000000..f5dce9a13
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContent.php
@@ -0,0 +1,2994 @@
+id;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Content The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ContentPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return Content The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = ContentPeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Content The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ContentPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Content The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ContentPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Content The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ContentPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->visible = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = ContentPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Content object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ContentPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collContentAssocs = null;
+
+ $this->collContentDescs = null;
+
+ $this->collContentFolders = null;
+
+ $this->collDocuments = null;
+
+ $this->collImages = null;
+
+ $this->collRewritings = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ContentQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ContentPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ContentPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ContentPeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(ContentPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(ContentPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ContentPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `content` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`VISIBLE`':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ContentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getVisible();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Content'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Content'][$this->getPrimaryKey()] = true;
+ $keys = ContentPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getVisible(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentDescs) {
+ $result['ContentDescs'] = $this->collContentDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentFolders) {
+ $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ContentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setVisible($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ContentPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ContentPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentPeer::ID)) $criteria->add(ContentPeer::ID, $this->id);
+ if ($this->isColumnModified(ContentPeer::VISIBLE)) $criteria->add(ContentPeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(ContentPeer::POSITION)) $criteria->add(ContentPeer::POSITION, $this->position);
+ if ($this->isColumnModified(ContentPeer::CREATED_AT)) $criteria->add(ContentPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ContentPeer::UPDATED_AT)) $criteria->add(ContentPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ContentPeer::DATABASE_NAME);
+ $criteria->add(ContentPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Content (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getContentAssocs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentAssoc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentFolders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentFolder($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDocuments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocument($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getImages() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImage($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Content Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ContentPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ContentPeer();
+ }
+
+ 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.
+ *
+ * @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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param ContentAssoc $contentAssoc The contentAssoc object to add.
+ */
+ protected function doAddContentAssoc($contentAssoc)
+ {
+ $this->collContentAssocs[]= $contentAssoc;
+ $contentAssoc->setContent($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->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.
+ *
+ * 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 getContentDescs($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collContentDescsPartial && !$this->isNew();
+ if (null === $this->collContentDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentDescs) {
+ // return empty collection
+ $this->initContentDescs();
+ } else {
+ $collContentDescs = ContentDescQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collContentDescsPartial && count($collContentDescs)) {
+ $this->initContentDescs(false);
+
+ foreach($collContentDescs as $obj) {
+ if (false == $this->collContentDescs->contains($obj)) {
+ $this->collContentDescs->append($obj);
+ }
+ }
+
+ $this->collContentDescsPartial = true;
+ }
+
+ return $collContentDescs;
+ }
+
+ if($partial && $this->collContentDescs) {
+ foreach($this->collContentDescs as $obj) {
+ if($obj->isNew()) {
+ $collContentDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentDescs = $collContentDescs;
+ $this->collContentDescsPartial = false;
+ }
+ }
+
+ return $this->collContentDescs;
+ }
+
+ /**
+ * Sets a collection of ContentDesc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $contentDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setContentDescs(PropelCollection $contentDescs, PropelPDO $con = null)
+ {
+ $this->contentDescsScheduledForDeletion = $this->getContentDescs(new Criteria(), $con)->diff($contentDescs);
+
+ foreach ($this->contentDescsScheduledForDeletion as $contentDescRemoved) {
+ $contentDescRemoved->setContent(null);
+ }
+
+ $this->collContentDescs = null;
+ foreach ($contentDescs as $contentDesc) {
+ $this->addContentDesc($contentDesc);
+ }
+
+ $this->collContentDescs = $contentDescs;
+ $this->collContentDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related ContentDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ContentDesc objects.
+ * @throws PropelException
+ */
+ public function countContentDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collContentDescsPartial && !$this->isNew();
+ if (null === $this->collContentDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getContentDescs());
+ }
+ $query = ContentDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collContentDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a ContentDesc object to this object
+ * through the ContentDesc foreign key attribute.
+ *
+ * @param ContentDesc $l ContentDesc
+ * @return Content The current object (for fluent API support)
+ */
+ public function addContentDesc(ContentDesc $l)
+ {
+ if ($this->collContentDescs === null) {
+ $this->initContentDescs();
+ $this->collContentDescsPartial = true;
+ }
+ if (!$this->collContentDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddContentDesc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentDesc $contentDesc The contentDesc object to add.
+ */
+ protected function doAddContentDesc($contentDesc)
+ {
+ $this->collContentDescs[]= $contentDesc;
+ $contentDesc->setContent($this);
+ }
+
+ /**
+ * @param ContentDesc $contentDesc The contentDesc object to remove.
+ */
+ public function removeContentDesc($contentDesc)
+ {
+ if ($this->getContentDescs()->contains($contentDesc)) {
+ $this->collContentDescs->remove($this->collContentDescs->search($contentDesc));
+ if (null === $this->contentDescsScheduledForDeletion) {
+ $this->contentDescsScheduledForDeletion = clone $this->collContentDescs;
+ $this->contentDescsScheduledForDeletion->clear();
+ }
+ $this->contentDescsScheduledForDeletion[]= $contentDesc;
+ $contentDesc->setContent(null);
+ }
+ }
+
+ /**
+ * Clears out the collContentFolders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContentFolders()
+ */
+ public function clearContentFolders()
+ {
+ $this->collContentFolders = null; // important to set this to null since that means it is uninitialized
+ $this->collContentFoldersPartial = null;
+ }
+
+ /**
+ * reset is the collContentFolders collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialContentFolders($v = true)
+ {
+ $this->collContentFoldersPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentFolders collection.
+ *
+ * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initContentFolders($overrideExisting = true)
+ {
+ if (null !== $this->collContentFolders && !$overrideExisting) {
+ return;
+ }
+ $this->collContentFolders = new PropelObjectCollection();
+ $this->collContentFolders->setModel('ContentFolder');
+ }
+
+ /**
+ * Gets an array of ContentFolder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this Content is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects
+ * @throws PropelException
+ */
+ public function getContentFolders($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collContentFoldersPartial && !$this->isNew();
+ if (null === $this->collContentFolders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentFolders) {
+ // return empty collection
+ $this->initContentFolders();
+ } else {
+ $collContentFolders = ContentFolderQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collContentFoldersPartial && count($collContentFolders)) {
+ $this->initContentFolders(false);
+
+ foreach($collContentFolders as $obj) {
+ if (false == $this->collContentFolders->contains($obj)) {
+ $this->collContentFolders->append($obj);
+ }
+ }
+
+ $this->collContentFoldersPartial = true;
+ }
+
+ return $collContentFolders;
+ }
+
+ if($partial && $this->collContentFolders) {
+ foreach($this->collContentFolders as $obj) {
+ if($obj->isNew()) {
+ $collContentFolders[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentFolders = $collContentFolders;
+ $this->collContentFoldersPartial = false;
+ }
+ }
+
+ return $this->collContentFolders;
+ }
+
+ /**
+ * Sets a collection of ContentFolder objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $contentFolders A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null)
+ {
+ $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders);
+
+ foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) {
+ $contentFolderRemoved->setContent(null);
+ }
+
+ $this->collContentFolders = null;
+ foreach ($contentFolders as $contentFolder) {
+ $this->addContentFolder($contentFolder);
+ }
+
+ $this->collContentFolders = $contentFolders;
+ $this->collContentFoldersPartial = false;
+ }
+
+ /**
+ * Returns the number of related ContentFolder objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ContentFolder objects.
+ * @throws PropelException
+ */
+ public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collContentFoldersPartial && !$this->isNew();
+ if (null === $this->collContentFolders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentFolders) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getContentFolders());
+ }
+ $query = ContentFolderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collContentFolders);
+ }
+ }
+
+ /**
+ * Method called to associate a ContentFolder object to this object
+ * through the ContentFolder foreign key attribute.
+ *
+ * @param ContentFolder $l ContentFolder
+ * @return Content The current object (for fluent API support)
+ */
+ public function addContentFolder(ContentFolder $l)
+ {
+ if ($this->collContentFolders === null) {
+ $this->initContentFolders();
+ $this->collContentFoldersPartial = true;
+ }
+ if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddContentFolder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentFolder $contentFolder The contentFolder object to add.
+ */
+ protected function doAddContentFolder($contentFolder)
+ {
+ $this->collContentFolders[]= $contentFolder;
+ $contentFolder->setContent($this);
+ }
+
+ /**
+ * @param ContentFolder $contentFolder The contentFolder object to remove.
+ */
+ public function removeContentFolder($contentFolder)
+ {
+ if ($this->getContentFolders()->contains($contentFolder)) {
+ $this->collContentFolders->remove($this->collContentFolders->search($contentFolder));
+ if (null === $this->contentFoldersScheduledForDeletion) {
+ $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders;
+ $this->contentFoldersScheduledForDeletion->clear();
+ }
+ $this->contentFoldersScheduledForDeletion[]= $contentFolder;
+ $contentFolder->setContent(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related ContentFolders from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects
+ */
+ public function getContentFoldersJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = ContentFolderQuery::create(null, $criteria);
+ $query->joinWith('Folder', $join_behavior);
+
+ return $this->getContentFolders($query, $con);
+ }
+
+ /**
+ * Clears out the collDocuments collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addDocuments()
+ */
+ public function clearDocuments()
+ {
+ $this->collDocuments = null; // important to set this to null since that means it is uninitialized
+ $this->collDocumentsPartial = null;
+ }
+
+ /**
+ * reset is the collDocuments collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialDocuments($v = true)
+ {
+ $this->collDocumentsPartial = $v;
+ }
+
+ /**
+ * Initializes the collDocuments collection.
+ *
+ * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initDocuments($overrideExisting = true)
+ {
+ if (null !== $this->collDocuments && !$overrideExisting) {
+ return;
+ }
+ $this->collDocuments = new PropelObjectCollection();
+ $this->collDocuments->setModel('Document');
+ }
+
+ /**
+ * Gets an array of Document objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this Content is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|Document[] List of Document objects
+ * @throws PropelException
+ */
+ public function getDocuments($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ // return empty collection
+ $this->initDocuments();
+ } else {
+ $collDocuments = DocumentQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentsPartial && count($collDocuments)) {
+ $this->initDocuments(false);
+
+ foreach($collDocuments as $obj) {
+ if (false == $this->collDocuments->contains($obj)) {
+ $this->collDocuments->append($obj);
+ }
+ }
+
+ $this->collDocumentsPartial = true;
+ }
+
+ return $collDocuments;
+ }
+
+ if($partial && $this->collDocuments) {
+ foreach($this->collDocuments as $obj) {
+ if($obj->isNew()) {
+ $collDocuments[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocuments = $collDocuments;
+ $this->collDocumentsPartial = false;
+ }
+ }
+
+ return $this->collDocuments;
+ }
+
+ /**
+ * Sets a collection of Document objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $documents A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setDocuments(PropelCollection $documents, PropelPDO $con = null)
+ {
+ $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents);
+
+ foreach ($this->documentsScheduledForDeletion as $documentRemoved) {
+ $documentRemoved->setContent(null);
+ }
+
+ $this->collDocuments = null;
+ foreach ($documents as $document) {
+ $this->addDocument($document);
+ }
+
+ $this->collDocuments = $documents;
+ $this->collDocumentsPartial = false;
+ }
+
+ /**
+ * Returns the number of related Document objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Document objects.
+ * @throws PropelException
+ */
+ public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getDocuments());
+ }
+ $query = DocumentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collDocuments);
+ }
+ }
+
+ /**
+ * Method called to associate a Document object to this object
+ * through the Document foreign key attribute.
+ *
+ * @param Document $l Document
+ * @return Content The current object (for fluent API support)
+ */
+ public function addDocument(Document $l)
+ {
+ if ($this->collDocuments === null) {
+ $this->initDocuments();
+ $this->collDocumentsPartial = true;
+ }
+ if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddDocument($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Document $document The document object to add.
+ */
+ protected function doAddDocument($document)
+ {
+ $this->collDocuments[]= $document;
+ $document->setContent($this);
+ }
+
+ /**
+ * @param Document $document The document object to remove.
+ */
+ public function removeDocument($document)
+ {
+ if ($this->getDocuments()->contains($document)) {
+ $this->collDocuments->remove($this->collDocuments->search($document));
+ if (null === $this->documentsScheduledForDeletion) {
+ $this->documentsScheduledForDeletion = clone $this->collDocuments;
+ $this->documentsScheduledForDeletion->clear();
+ }
+ $this->documentsScheduledForDeletion[]= $document;
+ $document->setContent(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Category', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Folder', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+ /**
+ * Clears out the collImages collection
+ *
+ * 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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param Image $image The image object to add.
+ */
+ protected function doAddImage($image)
+ {
+ $this->collImages[]= $image;
+ $image->setContent($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->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.
+ *
+ * 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 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)
+ ->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 {
+ 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 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);
+ }
+
+ /**
+ * @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->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 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);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ 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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContentAssoc.php b/core/lib/Thelia/Model/om/BaseContentAssoc.php
new file mode 100644
index 000000000..c98102990
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentAssoc.php
@@ -0,0 +1,1431 @@
+id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ContentAssoc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ContentAssocPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return ContentAssoc The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = ContentAssocPeer::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return ContentAssoc The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = ContentAssocPeer::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return ContentAssoc The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = ContentAssocPeer::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return ContentAssoc The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ContentAssocPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ContentAssoc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ContentAssocPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ContentAssoc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ContentAssocPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->category_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->product_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->content_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = ContentAssocPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ContentAssoc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ContentAssocPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ $this->aProduct = null;
+ $this->aContent = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ContentAssocQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ContentAssocPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ContentAssocPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentAssocPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentAssocPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ContentAssocPeer::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`';
+ }
+ if ($this->isColumnModified(ContentAssocPeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(ContentAssocPeer::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CONTENT_ID`';
+ }
+ if ($this->isColumnModified(ContentAssocPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(ContentAssocPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ContentAssocPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `content_assoc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CATEGORY_ID`':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`CONTENT_ID`':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ContentAssocPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCategoryId();
+ break;
+ case 2:
+ return $this->getProductId();
+ break;
+ case 3:
+ return $this->getContentId();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()] = true;
+ $keys = ContentAssocPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCategoryId(),
+ $keys[2] => $this->getProductId(),
+ $keys[3] => $this->getContentId(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ContentAssocPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCategoryId($value);
+ break;
+ case 2:
+ $this->setProductId($value);
+ break;
+ case 3:
+ $this->setContentId($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ContentAssocPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setContentId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentAssocPeer::ID)) $criteria->add(ContentAssocPeer::ID, $this->id);
+ if ($this->isColumnModified(ContentAssocPeer::CATEGORY_ID)) $criteria->add(ContentAssocPeer::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(ContentAssocPeer::PRODUCT_ID)) $criteria->add(ContentAssocPeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(ContentAssocPeer::CONTENT_ID)) $criteria->add(ContentAssocPeer::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(ContentAssocPeer::POSITION)) $criteria->add(ContentAssocPeer::POSITION, $this->position);
+ if ($this->isColumnModified(ContentAssocPeer::CREATED_AT)) $criteria->add(ContentAssocPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ContentAssocPeer::UPDATED_AT)) $criteria->add(ContentAssocPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
+ $criteria->add(ContentAssocPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ContentAssoc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ContentAssoc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ContentAssocPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ContentAssocPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return ContentAssoc 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->addContentAssoc($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->addContentAssocs($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return ContentAssoc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(Product $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->category_id = null;
+ $this->product_id = null;
+ $this->content_id = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ $this->aProduct = null;
+ $this->aContent = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentAssocPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContentAssocPeer.php b/core/lib/Thelia/Model/om/BaseContentAssocPeer.php
new file mode 100644
index 000000000..637af73d2
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentAssocPeer.php
@@ -0,0 +1,1773 @@
+ array ('Id', 'CategoryId', 'ProductId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'categoryId', 'productId', 'contentId', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ContentAssocPeer::ID, ContentAssocPeer::CATEGORY_ID, ContentAssocPeer::PRODUCT_ID, ContentAssocPeer::CONTENT_ID, ContentAssocPeer::POSITION, ContentAssocPeer::CREATED_AT, ContentAssocPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CATEGORY_ID', 'PRODUCT_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'category_id', 'product_id', 'content_id', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ContentAssocPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CategoryId' => 1, 'ProductId' => 2, 'ContentId' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'categoryId' => 1, 'productId' => 2, 'contentId' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (ContentAssocPeer::ID => 0, ContentAssocPeer::CATEGORY_ID => 1, ContentAssocPeer::PRODUCT_ID => 2, ContentAssocPeer::CONTENT_ID => 3, ContentAssocPeer::POSITION => 4, ContentAssocPeer::CREATED_AT => 5, ContentAssocPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CATEGORY_ID' => 1, 'PRODUCT_ID' => 2, 'CONTENT_ID' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'category_id' => 1, 'product_id' => 2, 'content_id' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ContentAssocPeer::getFieldNames($toType);
+ $key = isset(ContentAssocPeer::$fieldKeys[$fromType][$name]) ? ContentAssocPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ContentAssocPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ContentAssocPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ContentAssocPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ContentAssocPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ContentAssocPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentAssocPeer::ID);
+ $criteria->addSelectColumn(ContentAssocPeer::CATEGORY_ID);
+ $criteria->addSelectColumn(ContentAssocPeer::PRODUCT_ID);
+ $criteria->addSelectColumn(ContentAssocPeer::CONTENT_ID);
+ $criteria->addSelectColumn(ContentAssocPeer::POSITION);
+ $criteria->addSelectColumn(ContentAssocPeer::CREATED_AT);
+ $criteria->addSelectColumn(ContentAssocPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ContentAssoc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ContentAssocPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ContentAssocPeer::populateObjects(ContentAssocPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ContentAssocPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ContentAssoc $obj A ContentAssoc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ContentAssocPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ContentAssoc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ContentAssoc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ContentAssoc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ContentAssocPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ContentAssoc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ContentAssocPeer::$instances[$key])) {
+ return ContentAssocPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ContentAssocPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to content_assoc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ContentAssocPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ContentAssocPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentAssocPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ContentAssoc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ContentAssocPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentAssocPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ContentAssocPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ContentAssocPeer::DATABASE_NAME)->getTable(ContentAssocPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseContentAssocPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseContentAssocPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentAssocTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ContentAssocPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ContentAssoc or Criteria object.
+ *
+ * @param mixed $values Criteria or ContentAssoc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ContentAssoc object
+ }
+
+ if ($criteria->containsKey(ContentAssocPeer::ID) && $criteria->keyContainsValue(ContentAssocPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentAssocPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ContentAssoc or Criteria object.
+ *
+ * @param mixed $values Criteria or ContentAssoc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ContentAssocPeer::ID);
+ $value = $criteria->remove(ContentAssocPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ContentAssocPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ContentAssoc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the content_assoc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ContentAssocPeer::clearInstancePool();
+ ContentAssocPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ContentAssoc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ContentAssoc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ContentAssocPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ContentAssoc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ContentAssoc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ContentAssocPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ContentAssocPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ContentAssocPeer::DATABASE_NAME, ContentAssocPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return ContentAssoc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ContentAssocPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
+ $criteria->add(ContentAssocPeer::ID, $pk);
+
+ $v = ContentAssocPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return ContentAssoc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
+ $criteria->add(ContentAssocPeer::ID, $pks, Criteria::IN);
+ $objs = ContentAssocPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseContentAssocPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseContentAssocPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php
new file mode 100644
index 000000000..d36c9216c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php
@@ -0,0 +1,782 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ContentAssoc|ContentAssoc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentAssocPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ContentAssoc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CATEGORY_ID`, `PRODUCT_ID`, `CONTENT_ID`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `content_assoc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ContentAssoc();
+ $obj->hydrate($row);
+ ContentAssocPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ContentAssoc|ContentAssoc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ContentAssoc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ContentAssocPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ContentAssocPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ContentAssocPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(ContentAssocPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(ContentAssocPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocPeer::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ContentAssocPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ContentAssocPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ContentAssocPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ContentAssocPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 ContentAssocQuery 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(ContentAssocPeer::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentAssocPeer::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 ContentAssocQuery 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 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 ContentAssocQuery 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(ContentAssocPeer::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentAssocPeer::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 ContentAssocQuery 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 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
+ *
+ * @param ContentAssoc $contentAssoc Object to remove from the list of results
+ *
+ * @return ContentAssocQuery The current query, for fluid interface
+ */
+ public function prune($contentAssoc = null)
+ {
+ if ($contentAssoc) {
+ $this->addUsingAlias(ContentAssocPeer::ID, $contentAssoc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContentDesc.php b/core/lib/Thelia/Model/om/BaseContentDesc.php
new file mode 100644
index 000000000..decccecc6
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentDesc.php
@@ -0,0 +1,1375 @@
+id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->postscriptum;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ContentDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = ContentDescPeer::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = ContentDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ContentDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ContentDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ContentDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = ContentDescPeer::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ContentDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ContentDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ContentDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->content_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->postscriptum = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = ContentDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ContentDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ContentDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aContent = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ContentDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ContentDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ContentDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ContentDescPeer::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CONTENT_ID`';
+ }
+ if ($this->isColumnModified(ContentDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(ContentDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(ContentDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(ContentDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(ContentDescPeer::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`';
+ }
+ if ($this->isColumnModified(ContentDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ContentDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `content_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CONTENT_ID`':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`POSTSCRIPTUM`':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ContentDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getContentId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getPostscriptum();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ContentDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ContentDesc'][$this->getPrimaryKey()] = true;
+ $keys = ContentDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getContentId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getPostscriptum(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ContentDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setContentId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setPostscriptum($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ContentDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setContentId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setPostscriptum($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ContentDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentDescPeer::ID)) $criteria->add(ContentDescPeer::ID, $this->id);
+ if ($this->isColumnModified(ContentDescPeer::CONTENT_ID)) $criteria->add(ContentDescPeer::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(ContentDescPeer::LANG)) $criteria->add(ContentDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(ContentDescPeer::TITLE)) $criteria->add(ContentDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(ContentDescPeer::DESCRIPTION)) $criteria->add(ContentDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ContentDescPeer::CHAPO)) $criteria->add(ContentDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ContentDescPeer::POSTSCRIPTUM)) $criteria->add(ContentDescPeer::POSTSCRIPTUM, $this->postscriptum);
+ if ($this->isColumnModified(ContentDescPeer::CREATED_AT)) $criteria->add(ContentDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ContentDescPeer::UPDATED_AT)) $criteria->add(ContentDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ContentDescPeer::DATABASE_NAME);
+ $criteria->add(ContentDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ContentDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ContentDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ContentDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ContentDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Content object.
+ *
+ * @param Content $v
+ * @return ContentDesc 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->content_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aContent = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContentDescPeer.php b/core/lib/Thelia/Model/om/BaseContentDescPeer.php
new file mode 100644
index 000000000..4af41a9fd
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentDescPeer.php
@@ -0,0 +1,1042 @@
+ array ('Id', 'ContentId', 'Lang', 'Title', 'Description', 'Chapo', 'Postscriptum', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'contentId', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ContentDescPeer::ID, ContentDescPeer::CONTENT_ID, ContentDescPeer::LANG, ContentDescPeer::TITLE, ContentDescPeer::DESCRIPTION, ContentDescPeer::CHAPO, ContentDescPeer::POSTSCRIPTUM, ContentDescPeer::CREATED_AT, ContentDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CONTENT_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'content_id', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ContentDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ContentId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Postscriptum' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'contentId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ BasePeer::TYPE_COLNAME => array (ContentDescPeer::ID => 0, ContentDescPeer::CONTENT_ID => 1, ContentDescPeer::LANG => 2, ContentDescPeer::TITLE => 3, ContentDescPeer::DESCRIPTION => 4, ContentDescPeer::CHAPO => 5, ContentDescPeer::POSTSCRIPTUM => 6, ContentDescPeer::CREATED_AT => 7, ContentDescPeer::UPDATED_AT => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CONTENT_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'POSTSCRIPTUM' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'content_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ContentDescPeer::getFieldNames($toType);
+ $key = isset(ContentDescPeer::$fieldKeys[$fromType][$name]) ? ContentDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ContentDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ContentDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ContentDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ContentDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ContentDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentDescPeer::ID);
+ $criteria->addSelectColumn(ContentDescPeer::CONTENT_ID);
+ $criteria->addSelectColumn(ContentDescPeer::LANG);
+ $criteria->addSelectColumn(ContentDescPeer::TITLE);
+ $criteria->addSelectColumn(ContentDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(ContentDescPeer::CHAPO);
+ $criteria->addSelectColumn(ContentDescPeer::POSTSCRIPTUM);
+ $criteria->addSelectColumn(ContentDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(ContentDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ContentDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ContentDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ContentDescPeer::populateObjects(ContentDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ContentDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ContentDesc $obj A ContentDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ContentDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ContentDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ContentDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ContentDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ContentDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ContentDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ContentDescPeer::$instances[$key])) {
+ return ContentDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ContentDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to content_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ContentDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ContentDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ContentDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ContentDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ContentDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ContentDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ContentDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ContentDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ContentDescPeer::DATABASE_NAME)->getTable(ContentDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseContentDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseContentDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ContentDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ContentDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ContentDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ContentDesc object
+ }
+
+ if ($criteria->containsKey(ContentDescPeer::ID) && $criteria->keyContainsValue(ContentDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ContentDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ContentDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ContentDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ContentDescPeer::ID);
+ $value = $criteria->remove(ContentDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ContentDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ContentDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ContentDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the content_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ContentDescPeer::clearInstancePool();
+ ContentDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ContentDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ContentDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ContentDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ContentDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ContentDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ContentDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ContentDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ContentDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ContentDescPeer::DATABASE_NAME, ContentDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return ContentDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ContentDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ContentDescPeer::DATABASE_NAME);
+ $criteria->add(ContentDescPeer::ID, $pk);
+
+ $v = ContentDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return ContentDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ContentDescPeer::DATABASE_NAME);
+ $criteria->add(ContentDescPeer::ID, $pks, Criteria::IN);
+ $objs = ContentDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseContentDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseContentDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseContentDescQuery.php b/core/lib/Thelia/Model/om/BaseContentDescQuery.php
new file mode 100644
index 000000000..4e78ae8e9
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentDescQuery.php
@@ -0,0 +1,646 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ContentDesc|ContentDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ContentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ContentDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CONTENT_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM`, `CREATED_AT`, `UPDATED_AT` FROM `content_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ContentDesc();
+ $obj->hydrate($row);
+ ContentDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ContentDesc|ContentDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ContentDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ContentDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ContentDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(ContentDescPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(ContentDescPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ContentDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ContentDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ContentDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ContentDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 ContentDescQuery 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(ContentDescPeer::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentDescPeer::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 ContentDescQuery 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');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ContentDesc $contentDesc Object to remove from the list of results
+ *
+ * @return ContentDescQuery The current query, for fluid interface
+ */
+ public function prune($contentDesc = null)
+ {
+ if ($contentDesc) {
+ $this->addUsingAlias(ContentDescPeer::ID, $contentDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContentFolder.php b/core/lib/Thelia/Model/om/BaseContentFolder.php
new file mode 100644
index 000000000..83fe4363c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentFolder.php
@@ -0,0 +1,1009 @@
+content_id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+ return $this->folder_id;
+ }
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return ContentFolder The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = ContentFolderPeer::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return ContentFolder The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = ContentFolderPeer::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->content_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->folder_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 2; // 2 = ContentFolderPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ContentFolder object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ContentFolderPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aContent = null;
+ $this->aFolder = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ContentFolderQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ContentFolderPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentFolderPeer::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CONTENT_ID`';
+ }
+ if ($this->isColumnModified(ContentFolderPeer::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FOLDER_ID`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `content_folder` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`CONTENT_ID`':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case '`FOLDER_ID`':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ContentFolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getContentId();
+ break;
+ case 1:
+ return $this->getFolderId();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ContentFolder'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ContentFolder'][serialize($this->getPrimaryKey())] = true;
+ $keys = ContentFolderPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getContentId(),
+ $keys[1] => $this->getFolderId(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ContentFolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setContentId($value);
+ break;
+ case 1:
+ $this->setFolderId($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ContentFolderPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setContentId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ContentFolderPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentFolderPeer::CONTENT_ID)) $criteria->add(ContentFolderPeer::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(ContentFolderPeer::FOLDER_ID)) $criteria->add(ContentFolderPeer::FOLDER_ID, $this->folder_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ContentFolderPeer::DATABASE_NAME);
+ $criteria->add(ContentFolderPeer::CONTENT_ID, $this->content_id);
+ $criteria->add(ContentFolderPeer::FOLDER_ID, $this->folder_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getContentId();
+ $pks[1] = $this->getFolderId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setContentId($keys[0]);
+ $this->setFolderId($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getContentId()) && (null === $this->getFolderId());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ContentFolder (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setFolderId($this->getFolderId());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ContentFolder Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ContentFolderPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ContentFolderPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Content object.
+ *
+ * @param Content $v
+ * @return ContentFolder 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->addContentFolder($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->addContentFolders($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Declares an association between this object and a Folder object.
+ *
+ * @param Folder $v
+ * @return ContentFolder 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->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
+ */
+ public function clear()
+ {
+ $this->content_id = null;
+ $this->folder_id = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aContent = null;
+ $this->aFolder = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentFolderPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php
new file mode 100644
index 000000000..d0168ded1
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php
@@ -0,0 +1,1383 @@
+ array ('ContentId', 'FolderId', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('contentId', 'folderId', ),
+ BasePeer::TYPE_COLNAME => array (ContentFolderPeer::CONTENT_ID, ContentFolderPeer::FOLDER_ID, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('CONTENT_ID', 'FOLDER_ID', ),
+ BasePeer::TYPE_FIELDNAME => array ('content_id', 'folder_id', ),
+ BasePeer::TYPE_NUM => array (0, 1, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ContentFolderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('ContentId' => 0, 'FolderId' => 1, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('contentId' => 0, 'folderId' => 1, ),
+ BasePeer::TYPE_COLNAME => array (ContentFolderPeer::CONTENT_ID => 0, ContentFolderPeer::FOLDER_ID => 1, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('CONTENT_ID' => 0, 'FOLDER_ID' => 1, ),
+ BasePeer::TYPE_FIELDNAME => array ('content_id' => 0, 'folder_id' => 1, ),
+ BasePeer::TYPE_NUM => array (0, 1, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ContentFolderPeer::getFieldNames($toType);
+ $key = isset(ContentFolderPeer::$fieldKeys[$fromType][$name]) ? ContentFolderPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ContentFolderPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ContentFolderPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ContentFolderPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ContentFolderPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ContentFolderPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentFolderPeer::CONTENT_ID);
+ $criteria->addSelectColumn(ContentFolderPeer::FOLDER_ID);
+ } else {
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ContentFolder
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ContentFolderPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ContentFolderPeer::populateObjects(ContentFolderPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ContentFolderPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ContentFolder $obj A ContentFolder object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = serialize(array((string) $obj->getContentId(), (string) $obj->getFolderId()));
+ } // if key === null
+ ContentFolderPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ContentFolder object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ContentFolder) {
+ $key = serialize(array((string) $value->getContentId(), (string) $value->getFolderId()));
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ContentFolder object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ContentFolderPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ContentFolder Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ContentFolderPeer::$instances[$key])) {
+ return ContentFolderPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ContentFolderPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to content_folder
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null && $row[$startcol + 1] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return array((int) $row[$startcol], (int) $row[$startcol + 1]);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ContentFolderPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ContentFolderPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentFolderPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ContentFolder object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ContentFolderPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ContentFolderPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentFolderPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ContentFolderPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ContentFolderPeer::DATABASE_NAME)->getTable(ContentFolderPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseContentFolderPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseContentFolderPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentFolderTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ContentFolderPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ContentFolder or Criteria object.
+ *
+ * @param mixed $values Criteria or ContentFolder object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ContentFolder object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ContentFolder or Criteria object.
+ *
+ * @param mixed $values Criteria or ContentFolder object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ContentFolderPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ContentFolderPeer::CONTENT_ID);
+ $value = $criteria->remove(ContentFolderPeer::CONTENT_ID);
+ if ($value) {
+ $selectCriteria->add(ContentFolderPeer::CONTENT_ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(ContentFolderPeer::FOLDER_ID);
+ $value = $criteria->remove(ContentFolderPeer::FOLDER_ID);
+ if ($value) {
+ $selectCriteria->add(ContentFolderPeer::FOLDER_ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ContentFolder object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the content_folder table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ContentFolderPeer::clearInstancePool();
+ ContentFolderPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ContentFolder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ContentFolder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria = new Criteria(ContentFolderPeer::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $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);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ContentFolderPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ContentFolder object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ContentFolder $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ContentFolderPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ContentFolderPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ContentFolderPeer::DATABASE_NAME, ContentFolderPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve object using using composite pkey values.
+ * @param int $content_id
+ * @param int $folder_id
+ * @param PropelPDO $con
+ * @return ContentFolder
+ */
+ public static function retrieveByPK($content_id, $folder_id, PropelPDO $con = null) {
+ $_instancePoolKey = serialize(array((string) $content_id, (string) $folder_id));
+ if (null !== ($obj = ContentFolderPeer::getInstanceFromPool($_instancePoolKey))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $criteria = new Criteria(ContentFolderPeer::DATABASE_NAME);
+ $criteria->add(ContentFolderPeer::CONTENT_ID, $content_id);
+ $criteria->add(ContentFolderPeer::FOLDER_ID, $folder_id);
+ $v = ContentFolderPeer::doSelect($criteria, $con);
+
+ return !empty($v) ? $v[0] : null;
+ }
+} // BaseContentFolderPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseContentFolderPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php
new file mode 100644
index 000000000..ad5dffc3a
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php
@@ -0,0 +1,471 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array $key Primary key to use for the query
+ A Primary key composition: [$content_id, $folder_id]
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ContentFolder|ContentFolder[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentFolderPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ContentFolder A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `CONTENT_ID`, `FOLDER_ID` FROM `content_folder` WHERE `CONTENT_ID` = :p0 AND `FOLDER_ID` = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ContentFolder();
+ $obj->hydrate($row);
+ ContentFolderPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ContentFolder|ContentFolder[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ContentFolder[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ContentFolderPeer::CONTENT_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ContentFolderPeer::FOLDER_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * 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 ContentFolderQuery 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(ContentFolderPeer::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentFolderPeer::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 ContentFolderQuery 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(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentFolderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof Folder) {
+ return $this
+ ->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentFolderPeer::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 ContentFolderQuery 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');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ContentFolder $contentFolder Object to remove from the list of results
+ *
+ * @return ContentFolderQuery The current query, for fluid interface
+ */
+ public function prune($contentFolder = null)
+ {
+ if ($contentFolder) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ContentFolderPeer::CONTENT_ID), $contentFolder->getContentId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ContentFolderPeer::FOLDER_ID), $contentFolder->getFolderId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContentPeer.php b/core/lib/Thelia/Model/om/BaseContentPeer.php
new file mode 100644
index 000000000..85f317aa4
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentPeer.php
@@ -0,0 +1,807 @@
+ array ('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'visible', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ContentPeer::ID, ContentPeer::VISIBLE, ContentPeer::POSITION, ContentPeer::CREATED_AT, ContentPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'visible', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ContentPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (ContentPeer::ID => 0, ContentPeer::VISIBLE => 1, ContentPeer::POSITION => 2, ContentPeer::CREATED_AT => 3, ContentPeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ContentPeer::getFieldNames($toType);
+ $key = isset(ContentPeer::$fieldKeys[$fromType][$name]) ? ContentPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ContentPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ContentPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ContentPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ContentPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ContentPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentPeer::ID);
+ $criteria->addSelectColumn(ContentPeer::VISIBLE);
+ $criteria->addSelectColumn(ContentPeer::POSITION);
+ $criteria->addSelectColumn(ContentPeer::CREATED_AT);
+ $criteria->addSelectColumn(ContentPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ContentPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Content
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ContentPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ContentPeer::populateObjects(ContentPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ContentPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Content $obj A Content object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ContentPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Content object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Content) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Content object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ContentPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Content Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ContentPeer::$instances[$key])) {
+ return ContentPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ContentPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to content
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ContentPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ContentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ContentPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Content object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ContentPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ContentPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ContentPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ContentPeer::DATABASE_NAME)->getTable(ContentPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseContentPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseContentPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ContentPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Content or Criteria object.
+ *
+ * @param mixed $values Criteria or Content object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Content object
+ }
+
+ if ($criteria->containsKey(ContentPeer::ID) && $criteria->keyContainsValue(ContentPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Content or Criteria object.
+ *
+ * @param mixed $values Criteria or Content object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ContentPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ContentPeer::ID);
+ $value = $criteria->remove(ContentPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ContentPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ContentPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Content object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ContentPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the content table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(ContentPeer::TABLE_NAME, $con, ContentPeer::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
+ // instances get re-added by the select statement contained therein).
+ ContentPeer::clearInstancePool();
+ ContentPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Content or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Content object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ ContentPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Content) { // it's a model object
+ // invalidate the cache for this single object
+ ContentPeer::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(ContentPeer::DATABASE_NAME);
+ $criteria->add(ContentPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ContentPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ContentPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Content object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Content $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ContentPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ContentPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ContentPeer::DATABASE_NAME, ContentPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Content
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ContentPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ContentPeer::DATABASE_NAME);
+ $criteria->add(ContentPeer::ID, $pk);
+
+ $v = ContentPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Content[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ContentPeer::DATABASE_NAME);
+ $criteria->add(ContentPeer::ID, $pks, Criteria::IN);
+ $objs = ContentPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseContentPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseContentPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseContentQuery.php b/core/lib/Thelia/Model/om/BaseContentQuery.php
new file mode 100644
index 000000000..6c0e852ed
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentQuery.php
@@ -0,0 +1,917 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Content|Content[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Content A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `content` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Content();
+ $obj->hydrate($row);
+ ContentPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Content|Content[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Content[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ContentPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ContentPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ContentPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(ContentPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(ContentPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentPeer::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ContentPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ContentPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ContentPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ContentPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related ContentAssoc object
+ *
+ * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContentAssoc($contentAssoc, $comparison = null)
+ {
+ if ($contentAssoc instanceof ContentAssoc) {
+ return $this
+ ->addUsingAlias(ContentPeer::ID, $contentAssoc->getContentId(), $comparison);
+ } elseif ($contentAssoc instanceof PropelObjectCollection) {
+ return $this
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentAssoc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentAssoc');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentAssoc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentAssoc relation ContentAssoc object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
+ */
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContentAssoc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery');
+ }
+
+ /**
+ * Filter the query by a related ContentDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContentDesc($contentDesc, $comparison = null)
+ {
+ if ($contentDesc instanceof ContentDesc) {
+ return $this
+ ->addUsingAlias(ContentPeer::ID, $contentDesc->getContentId(), $comparison);
+ } elseif ($contentDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useContentDescQuery()
+ ->filterByPrimaryKeys($contentDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentDesc() only accepts arguments of type ContentDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function joinContentDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentDesc');
+
+ // 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, 'ContentDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentDesc relation ContentDesc 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\ContentDescQuery A secondary query class using the current class as primary query
+ */
+ public function useContentDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContentDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentDesc', '\Thelia\Model\ContentDescQuery');
+ }
+
+ /**
+ * Filter the query by a related ContentFolder object
+ *
+ * @param ContentFolder|PropelObjectCollection $contentFolder the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContentFolder($contentFolder, $comparison = null)
+ {
+ if ($contentFolder instanceof ContentFolder) {
+ return $this
+ ->addUsingAlias(ContentPeer::ID, $contentFolder->getContentId(), $comparison);
+ } elseif ($contentFolder instanceof PropelObjectCollection) {
+ return $this
+ ->useContentFolderQuery()
+ ->filterByPrimaryKeys($contentFolder->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentFolder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentFolder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentFolder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentFolder relation ContentFolder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query
+ */
+ public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContentFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery');
+ }
+
+ /**
+ * Filter the query by a related Document object
+ *
+ * @param Document|PropelObjectCollection $document the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof Document) {
+ return $this
+ ->addUsingAlias(ContentPeer::ID, $document->getContentId(), $comparison);
+ } elseif ($document instanceof PropelObjectCollection) {
+ return $this
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Filter the query by a related Image object
+ *
+ * @param Image|PropelObjectCollection $image the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof Image) {
+ return $this
+ ->addUsingAlias(ContentPeer::ID, $image->getContentId(), $comparison);
+ } elseif ($image instanceof PropelObjectCollection) {
+ return $this
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Filter the query by a related Rewriting object
+ *
+ * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByRewriting($rewriting, $comparison = null)
+ {
+ if ($rewriting instanceof Rewriting) {
+ return $this
+ ->addUsingAlias(ContentPeer::ID, $rewriting->getContentId(), $comparison);
+ } elseif ($rewriting instanceof PropelObjectCollection) {
+ return $this
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Rewriting relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Rewriting');
+
+ // 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, 'Rewriting');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Rewriting relation Rewriting 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\RewritingQuery A secondary query class using the current class as primary query
+ */
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinRewriting($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Content $content Object to remove from the list of results
+ *
+ * @return ContentQuery The current query, for fluid interface
+ */
+ public function prune($content = null)
+ {
+ if ($content) {
+ $this->addUsingAlias(ContentPeer::ID, $content->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCountry.php b/core/lib/Thelia/Model/om/BaseCountry.php
new file mode 100644
index 000000000..b19a6f777
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCountry.php
@@ -0,0 +1,1858 @@
+id;
+ }
+
+ /**
+ * Get the [area_id] column value.
+ *
+ * @return int
+ */
+ public function getAreaId()
+ {
+ return $this->area_id;
+ }
+
+ /**
+ * Get the [isocode] column value.
+ *
+ * @return string
+ */
+ public function getIsocode()
+ {
+ return $this->isocode;
+ }
+
+ /**
+ * Get the [isoalpha2] column value.
+ *
+ * @return string
+ */
+ public function getIsoalpha2()
+ {
+ return $this->isoalpha2;
+ }
+
+ /**
+ * Get the [isoalpha3] column value.
+ *
+ * @return string
+ */
+ public function getIsoalpha3()
+ {
+ return $this->isoalpha3;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Country The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CountryPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [area_id] column.
+ *
+ * @param int $v new value
+ * @return Country The current object (for fluent API support)
+ */
+ public function setAreaId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->area_id !== $v) {
+ $this->area_id = $v;
+ $this->modifiedColumns[] = CountryPeer::AREA_ID;
+ }
+
+ if ($this->aArea !== null && $this->aArea->getId() !== $v) {
+ $this->aArea = null;
+ }
+
+
+ return $this;
+ } // setAreaId()
+
+ /**
+ * Set the value of [isocode] column.
+ *
+ * @param string $v new value
+ * @return Country The current object (for fluent API support)
+ */
+ public function setIsocode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->isocode !== $v) {
+ $this->isocode = $v;
+ $this->modifiedColumns[] = CountryPeer::ISOCODE;
+ }
+
+
+ return $this;
+ } // setIsocode()
+
+ /**
+ * Set the value of [isoalpha2] column.
+ *
+ * @param string $v new value
+ * @return Country The current object (for fluent API support)
+ */
+ public function setIsoalpha2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->isoalpha2 !== $v) {
+ $this->isoalpha2 = $v;
+ $this->modifiedColumns[] = CountryPeer::ISOALPHA2;
+ }
+
+
+ return $this;
+ } // setIsoalpha2()
+
+ /**
+ * Set the value of [isoalpha3] column.
+ *
+ * @param string $v new value
+ * @return Country The current object (for fluent API support)
+ */
+ public function setIsoalpha3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->isoalpha3 !== $v) {
+ $this->isoalpha3 = $v;
+ $this->modifiedColumns[] = CountryPeer::ISOALPHA3;
+ }
+
+
+ return $this;
+ } // setIsoalpha3()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Country The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CountryPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Country The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CountryPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->area_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->isocode = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->isoalpha2 = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->isoalpha3 = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = CountryPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Country object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) {
+ $this->aArea = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CountryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aArea = null;
+ $this->collCountryDescs = null;
+
+ $this->collTaxRuleCountrys = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CountryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CountryPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->countryDescsScheduledForDeletion !== null) {
+ if (!$this->countryDescsScheduledForDeletion->isEmpty()) {
+ CountryDescQuery::create()
+ ->filterByPrimaryKeys($this->countryDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->countryDescsScheduledForDeletion = null;
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CountryPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CountryPeer::AREA_ID)) {
+ $modifiedColumns[':p' . $index++] = '`AREA_ID`';
+ }
+ if ($this->isColumnModified(CountryPeer::ISOCODE)) {
+ $modifiedColumns[':p' . $index++] = '`ISOCODE`';
+ }
+ if ($this->isColumnModified(CountryPeer::ISOALPHA2)) {
+ $modifiedColumns[':p' . $index++] = '`ISOALPHA2`';
+ }
+ if ($this->isColumnModified(CountryPeer::ISOALPHA3)) {
+ $modifiedColumns[':p' . $index++] = '`ISOALPHA3`';
+ }
+ if ($this->isColumnModified(CountryPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CountryPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `country` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`AREA_ID`':
+ $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT);
+ break;
+ case '`ISOCODE`':
+ $stmt->bindValue($identifier, $this->isocode, PDO::PARAM_STR);
+ break;
+ case '`ISOALPHA2`':
+ $stmt->bindValue($identifier, $this->isoalpha2, PDO::PARAM_STR);
+ break;
+ case '`ISOALPHA3`':
+ $stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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 = CountryPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ 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());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getAreaId();
+ break;
+ case 2:
+ return $this->getIsocode();
+ break;
+ case 3:
+ return $this->getIsoalpha2();
+ break;
+ case 4:
+ return $this->getIsoalpha3();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Country'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Country'][$this->getPrimaryKey()] = true;
+ $keys = CountryPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAreaId(),
+ $keys[2] => $this->getIsocode(),
+ $keys[3] => $this->getIsoalpha2(),
+ $keys[4] => $this->getIsoalpha3(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aArea) {
+ $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collCountryDescs) {
+ $result['CountryDescs'] = $this->collCountryDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collTaxRuleCountrys) {
+ $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setAreaId($value);
+ break;
+ case 2:
+ $this->setIsocode($value);
+ break;
+ case 3:
+ $this->setIsoalpha2($value);
+ break;
+ case 4:
+ $this->setIsoalpha3($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CountryPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setIsocode($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setIsoalpha2($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setIsoalpha3($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CountryPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CountryPeer::ID)) $criteria->add(CountryPeer::ID, $this->id);
+ if ($this->isColumnModified(CountryPeer::AREA_ID)) $criteria->add(CountryPeer::AREA_ID, $this->area_id);
+ if ($this->isColumnModified(CountryPeer::ISOCODE)) $criteria->add(CountryPeer::ISOCODE, $this->isocode);
+ if ($this->isColumnModified(CountryPeer::ISOALPHA2)) $criteria->add(CountryPeer::ISOALPHA2, $this->isoalpha2);
+ if ($this->isColumnModified(CountryPeer::ISOALPHA3)) $criteria->add(CountryPeer::ISOALPHA3, $this->isoalpha3);
+ if ($this->isColumnModified(CountryPeer::CREATED_AT)) $criteria->add(CountryPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CountryPeer::UPDATED_AT)) $criteria->add(CountryPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CountryPeer::DATABASE_NAME);
+ $criteria->add(CountryPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Country (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAreaId($this->getAreaId());
+ $copyObj->setIsocode($this->getIsocode());
+ $copyObj->setIsoalpha2($this->getIsoalpha2());
+ $copyObj->setIsoalpha3($this->getIsoalpha3());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ foreach ($this->getTaxRuleCountrys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxRuleCountry($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Country Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CountryPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CountryPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Area object.
+ *
+ * @param Area $v
+ * @return Country The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setArea(Area $v = null)
+ {
+ 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->addCountry($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->addCountrys($this);
+ */
+ }
+
+ return $this->aArea;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CountryDesc' == $relationName) {
+ $this->initCountryDescs();
+ }
+ if ('TaxRuleCountry' == $relationName) {
+ $this->initTaxRuleCountrys();
+ }
+ }
+
+ /**
+ * 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 PropelObjectCollection|CountryDesc[] List of CountryDesc objects
+ * @throws PropelException
+ */
+ 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);
+
+ 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->collCountryDescs;
+ }
+
+ /**
+ * 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 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 countCountryDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $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();
+ }
+
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->area_id = null;
+ $this->isocode = null;
+ $this->isoalpha2 = null;
+ $this->isoalpha3 = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($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->collCountryDescs instanceof PropelCollection) {
+ $this->collCountryDescs->clearIterator();
+ }
+ $this->collCountryDescs = null;
+ if ($this->collTaxRuleCountrys instanceof PropelCollection) {
+ $this->collTaxRuleCountrys->clearIterator();
+ }
+ $this->collTaxRuleCountrys = null;
+ $this->aArea = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CountryPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCountryDesc.php b/core/lib/Thelia/Model/om/BaseCountryDesc.php
new file mode 100644
index 000000000..105007c9b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCountryDesc.php
@@ -0,0 +1,1320 @@
+id;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return CountryDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CountryDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return CountryDesc The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = CountryDescPeer::COUNTRY_ID;
+ }
+
+ if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
+ $this->aCountry = null;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return CountryDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = CountryDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return CountryDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = CountryDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return CountryDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = CountryDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return CountryDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = CountryDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CountryDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CountryDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CountryDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CountryDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->country_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = CountryDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CountryDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
+ $this->aCountry = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CountryDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCountry = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CountryDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CountryDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CountryDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CountryDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CountryDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CountryDescPeer::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`';
+ }
+ if ($this->isColumnModified(CountryDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(CountryDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(CountryDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(CountryDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(CountryDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CountryDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `country_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`COUNTRY_ID`':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CountryDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCountryId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CountryDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CountryDesc'][$this->getPrimaryKey()] = true;
+ $keys = CountryDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCountryId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCountry) {
+ $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CountryDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCountryId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CountryDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCountryId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CountryDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CountryDescPeer::ID)) $criteria->add(CountryDescPeer::ID, $this->id);
+ if ($this->isColumnModified(CountryDescPeer::COUNTRY_ID)) $criteria->add(CountryDescPeer::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(CountryDescPeer::LANG)) $criteria->add(CountryDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(CountryDescPeer::TITLE)) $criteria->add(CountryDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(CountryDescPeer::DESCRIPTION)) $criteria->add(CountryDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(CountryDescPeer::CHAPO)) $criteria->add(CountryDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(CountryDescPeer::CREATED_AT)) $criteria->add(CountryDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CountryDescPeer::UPDATED_AT)) $criteria->add(CountryDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CountryDescPeer::DATABASE_NAME);
+ $criteria->add(CountryDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CountryDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CountryDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CountryDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CountryDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Country object.
+ *
+ * @param Country $v
+ * @return CountryDesc 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->country_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCountry = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CountryDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCountryDescPeer.php b/core/lib/Thelia/Model/om/BaseCountryDescPeer.php
new file mode 100644
index 000000000..37394982f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCountryDescPeer.php
@@ -0,0 +1,1037 @@
+ array ('Id', 'CountryId', 'Lang', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'countryId', 'lang', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CountryDescPeer::ID, CountryDescPeer::COUNTRY_ID, CountryDescPeer::LANG, CountryDescPeer::TITLE, CountryDescPeer::DESCRIPTION, CountryDescPeer::CHAPO, CountryDescPeer::CREATED_AT, CountryDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'COUNTRY_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'country_id', 'lang', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CountryDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CountryId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'countryId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (CountryDescPeer::ID => 0, CountryDescPeer::COUNTRY_ID => 1, CountryDescPeer::LANG => 2, CountryDescPeer::TITLE => 3, CountryDescPeer::DESCRIPTION => 4, CountryDescPeer::CHAPO => 5, CountryDescPeer::CREATED_AT => 6, CountryDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'COUNTRY_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'country_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CountryDescPeer::getFieldNames($toType);
+ $key = isset(CountryDescPeer::$fieldKeys[$fromType][$name]) ? CountryDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CountryDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CountryDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CountryDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CountryDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CountryDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CountryDescPeer::ID);
+ $criteria->addSelectColumn(CountryDescPeer::COUNTRY_ID);
+ $criteria->addSelectColumn(CountryDescPeer::LANG);
+ $criteria->addSelectColumn(CountryDescPeer::TITLE);
+ $criteria->addSelectColumn(CountryDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(CountryDescPeer::CHAPO);
+ $criteria->addSelectColumn(CountryDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(CountryDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CountryDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CountryDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CountryDescPeer::populateObjects(CountryDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CountryDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CountryDesc $obj A CountryDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CountryDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CountryDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CountryDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CountryDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CountryDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CountryDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CountryDescPeer::$instances[$key])) {
+ return CountryDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CountryDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to country_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CountryDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CountryDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CountryDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CountryDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CountryDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CountryDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CountryDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CountryDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CountryDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CountryDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CountryDescPeer::DATABASE_NAME)->getTable(CountryDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCountryDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCountryDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CountryDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CountryDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CountryDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or CountryDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CountryDesc object
+ }
+
+ if ($criteria->containsKey(CountryDescPeer::ID) && $criteria->keyContainsValue(CountryDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CountryDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a CountryDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or CountryDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CountryDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CountryDescPeer::ID);
+ $value = $criteria->remove(CountryDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CountryDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CountryDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is CountryDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the country_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ CountryDescPeer::clearInstancePool();
+ CountryDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CountryDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CountryDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(CountryDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CountryDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CountryDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CountryDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CountryDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CountryDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CountryDescPeer::DATABASE_NAME, CountryDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CountryDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CountryDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CountryDescPeer::DATABASE_NAME);
+ $criteria->add(CountryDescPeer::ID, $pk);
+
+ $v = CountryDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return CountryDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CountryDescPeer::DATABASE_NAME);
+ $criteria->add(CountryDescPeer::ID, $pks, Criteria::IN);
+ $objs = CountryDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCountryDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCountryDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCountryDescQuery.php b/core/lib/Thelia/Model/om/BaseCountryDescQuery.php
new file mode 100644
index 000000000..3e71b9628
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCountryDescQuery.php
@@ -0,0 +1,613 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CountryDesc|CountryDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CountryDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CountryDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CountryDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `COUNTRY_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `country_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new CountryDesc();
+ $obj->hydrate($row);
+ CountryDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CountryDesc|CountryDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|CountryDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CountryDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CountryDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CountryDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @see filterByCountry()
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(CountryDescPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(CountryDescPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryDescPeer::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CountryDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CountryDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CountryDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CountryDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 CountryDescQuery 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(CountryDescPeer::COUNTRY_ID, $country->getId(), $comparison);
+ } elseif ($country instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CountryDescPeer::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 CountryDescQuery 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');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param CountryDesc $countryDesc Object to remove from the list of results
+ *
+ * @return CountryDescQuery The current query, for fluid interface
+ */
+ public function prune($countryDesc = null)
+ {
+ if ($countryDesc) {
+ $this->addUsingAlias(CountryDescPeer::ID, $countryDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCountryPeer.php b/core/lib/Thelia/Model/om/BaseCountryPeer.php
new file mode 100644
index 000000000..9566871ba
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCountryPeer.php
@@ -0,0 +1,1036 @@
+ array ('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CountryPeer::ID, CountryPeer::AREA_ID, CountryPeer::ISOCODE, CountryPeer::ISOALPHA2, CountryPeer::ISOALPHA3, CountryPeer::CREATED_AT, CountryPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CountryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (CountryPeer::ID => 0, CountryPeer::AREA_ID => 1, CountryPeer::ISOCODE => 2, CountryPeer::ISOALPHA2 => 3, CountryPeer::ISOALPHA3 => 4, CountryPeer::CREATED_AT => 5, CountryPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CountryPeer::getFieldNames($toType);
+ $key = isset(CountryPeer::$fieldKeys[$fromType][$name]) ? CountryPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CountryPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CountryPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CountryPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CountryPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CountryPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CountryPeer::ID);
+ $criteria->addSelectColumn(CountryPeer::AREA_ID);
+ $criteria->addSelectColumn(CountryPeer::ISOCODE);
+ $criteria->addSelectColumn(CountryPeer::ISOALPHA2);
+ $criteria->addSelectColumn(CountryPeer::ISOALPHA3);
+ $criteria->addSelectColumn(CountryPeer::CREATED_AT);
+ $criteria->addSelectColumn(CountryPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.AREA_ID');
+ $criteria->addSelectColumn($alias . '.ISOCODE');
+ $criteria->addSelectColumn($alias . '.ISOALPHA2');
+ $criteria->addSelectColumn($alias . '.ISOALPHA3');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CountryPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Country
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CountryPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CountryPeer::populateObjects(CountryPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CountryPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CountryPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Country $obj A Country object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CountryPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Country object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Country) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Country object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CountryPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Country Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CountryPeer::$instances[$key])) {
+ return CountryPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CountryPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to country
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in CountryDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CountryPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CountryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CountryPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Country object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CountryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CountryPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CountryPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CountryPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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(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::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 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
+ * @return array Array of Country 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(CountryPeer::DATABASE_NAME);
+ }
+
+ CountryPeer::addSelectColumns($criteria);
+ $startcol = CountryPeer::NUM_HYDRATE_COLUMNS;
+ AreaPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::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 = 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 (Country) to $obj2 (Area)
+ $obj2->addCountry($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(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::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 Country 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 Country 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(CountryPeer::DATABASE_NAME);
+ }
+
+ CountryPeer::addSelectColumns($criteria);
+ $startcol2 = CountryPeer::NUM_HYDRATE_COLUMNS;
+
+ AreaPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + AreaPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::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 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 (Country) to the collection in $obj2 (Area)
+ $obj2->addCountry($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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CountryPeer::DATABASE_NAME)->getTable(CountryPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCountryPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCountryPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CountryTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CountryPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Country or Criteria object.
+ *
+ * @param mixed $values Criteria or Country object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Country object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CountryPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Country or Criteria object.
+ *
+ * @param mixed $values Criteria or Country object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CountryPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CountryPeer::ID);
+ $value = $criteria->remove(CountryPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CountryPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CountryPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Country object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CountryPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the country table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ CountryPeer::clearInstancePool();
+ CountryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Country or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Country object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(CountryPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CountryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Country object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Country $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CountryPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CountryPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CountryPeer::DATABASE_NAME, CountryPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Country
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CountryPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CountryPeer::DATABASE_NAME);
+ $criteria->add(CountryPeer::ID, $pk);
+
+ $v = CountryPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Country[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CountryPeer::DATABASE_NAME);
+ $criteria->add(CountryPeer::ID, $pks, Criteria::IN);
+ $objs = CountryPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCountryPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCountryPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCountryQuery.php b/core/lib/Thelia/Model/om/BaseCountryQuery.php
new file mode 100644
index 000000000..27500b9fd
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCountryQuery.php
@@ -0,0 +1,738 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Country|Country[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CountryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Country A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `AREA_ID`, `ISOCODE`, `ISOALPHA2`, `ISOALPHA3`, `CREATED_AT`, `UPDATED_AT` FROM `country` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Country();
+ $obj->hydrate($row);
+ CountryPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Country|Country[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Country[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CountryPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CountryPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CountryPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the area_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAreaId(1234); // WHERE area_id = 1234
+ * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34)
+ * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12
+ *
+ *
+ * @see filterByArea()
+ *
+ * @param mixed $areaId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterByAreaId($areaId = null, $comparison = null)
+ {
+ if (is_array($areaId)) {
+ $useMinMax = false;
+ if (isset($areaId['min'])) {
+ $this->addUsingAlias(CountryPeer::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($areaId['max'])) {
+ $this->addUsingAlias(CountryPeer::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryPeer::AREA_ID, $areaId, $comparison);
+ }
+
+ /**
+ * Filter the query on the isocode column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsocode('fooValue'); // WHERE isocode = 'fooValue'
+ * $query->filterByIsocode('%fooValue%'); // WHERE isocode LIKE '%fooValue%'
+ *
+ *
+ * @param string $isocode The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterByIsocode($isocode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($isocode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $isocode)) {
+ $isocode = str_replace('*', '%', $isocode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryPeer::ISOCODE, $isocode, $comparison);
+ }
+
+ /**
+ * Filter the query on the isoalpha2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsoalpha2('fooValue'); // WHERE isoalpha2 = 'fooValue'
+ * $query->filterByIsoalpha2('%fooValue%'); // WHERE isoalpha2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $isoalpha2 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterByIsoalpha2($isoalpha2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($isoalpha2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $isoalpha2)) {
+ $isoalpha2 = str_replace('*', '%', $isoalpha2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryPeer::ISOALPHA2, $isoalpha2, $comparison);
+ }
+
+ /**
+ * Filter the query on the isoalpha3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsoalpha3('fooValue'); // WHERE isoalpha3 = 'fooValue'
+ * $query->filterByIsoalpha3('%fooValue%'); // WHERE isoalpha3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $isoalpha3 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterByIsoalpha3($isoalpha3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($isoalpha3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $isoalpha3)) {
+ $isoalpha3 = str_replace('*', '%', $isoalpha3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryPeer::ISOALPHA3, $isoalpha3, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CountryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CountryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CountryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CountryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ 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 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 filterByCountryDesc($countryDesc, $comparison = null)
+ {
+ if ($countryDesc instanceof CountryDesc) {
+ return $this
+ ->addUsingAlias(CountryPeer::ID, $countryDesc->getCountryId(), $comparison);
+ } elseif ($countryDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useCountryDescQuery()
+ ->filterByPrimaryKeys($countryDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCountryDesc() only accepts arguments of type CountryDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CountryDesc 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 joinCountryDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CountryDesc');
+
+ // 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, 'CountryDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CountryDesc relation CountryDesc 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\CountryDescQuery A secondary query class using the current class as primary query
+ */
+ public function useCountryDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCountryDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CountryDesc', '\Thelia\Model\CountryDescQuery');
+ }
+
+ /**
+ * Filter the query by a related TaxRuleCountry object
+ *
+ * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CountryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null)
+ {
+ if ($taxRuleCountry instanceof TaxRuleCountry) {
+ return $this
+ ->addUsingAlias(CountryPeer::ID, $taxRuleCountry->getCountryId(), $comparison);
+ } elseif ($taxRuleCountry instanceof PropelObjectCollection) {
+ return $this
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRuleCountry relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRuleCountry');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRuleCountry');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRuleCountry relation TaxRuleCountry object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRuleCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Country $country Object to remove from the list of results
+ *
+ * @return CountryQuery The current query, for fluid interface
+ */
+ public function prune($country = null)
+ {
+ if ($country) {
+ $this->addUsingAlias(CountryPeer::ID, $country->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCoupon.php b/core/lib/Thelia/Model/om/BaseCoupon.php
new file mode 100644
index 000000000..6f2d237c2
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCoupon.php
@@ -0,0 +1,1678 @@
+id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [action] column value.
+ *
+ * @return string
+ */
+ public function getAction()
+ {
+ return $this->action;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return double
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Get the [used] column value.
+ *
+ * @return int
+ */
+ public function getUsed()
+ {
+ return $this->used;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [available_since] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getAvailableSince($format = 'Y-m-d H:i:s')
+ {
+ if ($this->available_since === null) {
+ return null;
+ }
+
+ if ($this->available_since === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->available_since);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->available_since, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [date_limit] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getDateLimit($format = 'Y-m-d H:i:s')
+ {
+ if ($this->date_limit === null) {
+ return null;
+ }
+
+ if ($this->date_limit === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->date_limit);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->date_limit, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [activate] column value.
+ *
+ * @return int
+ */
+ public function getActivate()
+ {
+ return $this->activate;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CouponPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = CouponPeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [action] column.
+ *
+ * @param string $v new value
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setAction($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->action !== $v) {
+ $this->action = $v;
+ $this->modifiedColumns[] = CouponPeer::ACTION;
+ }
+
+
+ return $this;
+ } // setAction()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param double $v new value
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = CouponPeer::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Set the value of [used] column.
+ *
+ * @param int $v new value
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setUsed($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->used !== $v) {
+ $this->used = $v;
+ $this->modifiedColumns[] = CouponPeer::USED;
+ }
+
+
+ return $this;
+ } // setUsed()
+
+ /**
+ * Sets the value of [available_since] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setAvailableSince($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->available_since !== null || $dt !== null) {
+ $currentDateAsString = ($this->available_since !== null && $tmpDt = new DateTime($this->available_since)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->available_since = $newDateAsString;
+ $this->modifiedColumns[] = CouponPeer::AVAILABLE_SINCE;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setAvailableSince()
+
+ /**
+ * Sets the value of [date_limit] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setDateLimit($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->date_limit !== null || $dt !== null) {
+ $currentDateAsString = ($this->date_limit !== null && $tmpDt = new DateTime($this->date_limit)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->date_limit = $newDateAsString;
+ $this->modifiedColumns[] = CouponPeer::DATE_LIMIT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setDateLimit()
+
+ /**
+ * Set the value of [activate] column.
+ *
+ * @param int $v new value
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setActivate($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->activate !== $v) {
+ $this->activate = $v;
+ $this->modifiedColumns[] = CouponPeer::ACTIVATE;
+ }
+
+
+ return $this;
+ } // setActivate()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CouponPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Coupon The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CouponPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->action = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->value = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null;
+ $this->used = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->available_since = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->date_limit = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->activate = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
+ $this->created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->updated_at = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 10; // 10 = CouponPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Coupon object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CouponPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collCouponRules = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CouponQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CouponPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CouponPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CouponPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CouponPeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(CouponPeer::ACTION)) {
+ $modifiedColumns[':p' . $index++] = '`ACTION`';
+ }
+ if ($this->isColumnModified(CouponPeer::VALUE)) {
+ $modifiedColumns[':p' . $index++] = '`VALUE`';
+ }
+ if ($this->isColumnModified(CouponPeer::USED)) {
+ $modifiedColumns[':p' . $index++] = '`USED`';
+ }
+ if ($this->isColumnModified(CouponPeer::AVAILABLE_SINCE)) {
+ $modifiedColumns[':p' . $index++] = '`AVAILABLE_SINCE`';
+ }
+ if ($this->isColumnModified(CouponPeer::DATE_LIMIT)) {
+ $modifiedColumns[':p' . $index++] = '`DATE_LIMIT`';
+ }
+ if ($this->isColumnModified(CouponPeer::ACTIVATE)) {
+ $modifiedColumns[':p' . $index++] = '`ACTIVATE`';
+ }
+ if ($this->isColumnModified(CouponPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CouponPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `coupon` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`ACTION`':
+ $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR);
+ break;
+ case '`VALUE`':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case '`USED`':
+ $stmt->bindValue($identifier, $this->used, PDO::PARAM_INT);
+ break;
+ case '`AVAILABLE_SINCE`':
+ $stmt->bindValue($identifier, $this->available_since, PDO::PARAM_STR);
+ break;
+ case '`DATE_LIMIT`':
+ $stmt->bindValue($identifier, $this->date_limit, PDO::PARAM_STR);
+ break;
+ case '`ACTIVATE`':
+ $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CouponPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getAction();
+ break;
+ case 3:
+ return $this->getValue();
+ break;
+ case 4:
+ return $this->getUsed();
+ break;
+ case 5:
+ return $this->getAvailableSince();
+ break;
+ case 6:
+ return $this->getDateLimit();
+ break;
+ case 7:
+ return $this->getActivate();
+ break;
+ case 8:
+ return $this->getCreatedAt();
+ break;
+ case 9:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Coupon'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Coupon'][$this->getPrimaryKey()] = true;
+ $keys = CouponPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getAction(),
+ $keys[3] => $this->getValue(),
+ $keys[4] => $this->getUsed(),
+ $keys[5] => $this->getAvailableSince(),
+ $keys[6] => $this->getDateLimit(),
+ $keys[7] => $this->getActivate(),
+ $keys[8] => $this->getCreatedAt(),
+ $keys[9] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collCouponRules) {
+ $result['CouponRules'] = $this->collCouponRules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CouponPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setAction($value);
+ break;
+ case 3:
+ $this->setValue($value);
+ break;
+ case 4:
+ $this->setUsed($value);
+ break;
+ case 5:
+ $this->setAvailableSince($value);
+ break;
+ case 6:
+ $this->setDateLimit($value);
+ break;
+ case 7:
+ $this->setActivate($value);
+ break;
+ case 8:
+ $this->setCreatedAt($value);
+ break;
+ case 9:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CouponPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAction($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setValue($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUsed($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setAvailableSince($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setDateLimit($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setActivate($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CouponPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CouponPeer::ID)) $criteria->add(CouponPeer::ID, $this->id);
+ if ($this->isColumnModified(CouponPeer::CODE)) $criteria->add(CouponPeer::CODE, $this->code);
+ if ($this->isColumnModified(CouponPeer::ACTION)) $criteria->add(CouponPeer::ACTION, $this->action);
+ if ($this->isColumnModified(CouponPeer::VALUE)) $criteria->add(CouponPeer::VALUE, $this->value);
+ if ($this->isColumnModified(CouponPeer::USED)) $criteria->add(CouponPeer::USED, $this->used);
+ if ($this->isColumnModified(CouponPeer::AVAILABLE_SINCE)) $criteria->add(CouponPeer::AVAILABLE_SINCE, $this->available_since);
+ if ($this->isColumnModified(CouponPeer::DATE_LIMIT)) $criteria->add(CouponPeer::DATE_LIMIT, $this->date_limit);
+ if ($this->isColumnModified(CouponPeer::ACTIVATE)) $criteria->add(CouponPeer::ACTIVATE, $this->activate);
+ if ($this->isColumnModified(CouponPeer::CREATED_AT)) $criteria->add(CouponPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CouponPeer::UPDATED_AT)) $criteria->add(CouponPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CouponPeer::DATABASE_NAME);
+ $criteria->add(CouponPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Coupon (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setAction($this->getAction());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setUsed($this->getUsed());
+ $copyObj->setAvailableSince($this->getAvailableSince());
+ $copyObj->setDateLimit($this->getDateLimit());
+ $copyObj->setActivate($this->getActivate());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Coupon Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CouponPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CouponPeer();
+ }
+
+ 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.
+ *
+ * @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 getCouponRules($criteria = null, PropelPDO $con = 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 {
+ return count($this->collCouponRules);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * @param CouponRule $couponRule The couponRule object to remove.
+ */
+ public function removeCouponRule($couponRule)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->action = null;
+ $this->value = null;
+ $this->used = null;
+ $this->available_since = null;
+ $this->date_limit = null;
+ $this->activate = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCouponRules) {
+ foreach ($this->collCouponRules as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collCouponRules instanceof PropelCollection) {
+ $this->collCouponRules->clearIterator();
+ }
+ $this->collCouponRules = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CouponPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCouponOrder.php b/core/lib/Thelia/Model/om/BaseCouponOrder.php
new file mode 100644
index 000000000..296fd0e6a
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCouponOrder.php
@@ -0,0 +1,1210 @@
+id;
+ }
+
+ /**
+ * Get the [order_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderId()
+ {
+ return $this->order_id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return double
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return CouponOrder The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CouponOrderPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [order_id] column.
+ *
+ * @param int $v new value
+ * @return CouponOrder The current object (for fluent API support)
+ */
+ public function setOrderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_id !== $v) {
+ $this->order_id = $v;
+ $this->modifiedColumns[] = CouponOrderPeer::ORDER_ID;
+ }
+
+ if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
+ $this->aOrder = null;
+ }
+
+
+ return $this;
+ } // setOrderId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return CouponOrder The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = CouponOrderPeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param double $v new value
+ * @return CouponOrder The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = CouponOrderPeer::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CouponOrder The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CouponOrderPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CouponOrder The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CouponOrderPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->order_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->code = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->value = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null;
+ $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = CouponOrderPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CouponOrder object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) {
+ $this->aOrder = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CouponOrderPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrder = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CouponOrderQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CouponOrderPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CouponOrderPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponOrderPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CouponOrderPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CouponOrderPeer::ORDER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ORDER_ID`';
+ }
+ if ($this->isColumnModified(CouponOrderPeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(CouponOrderPeer::VALUE)) {
+ $modifiedColumns[':p' . $index++] = '`VALUE`';
+ }
+ if ($this->isColumnModified(CouponOrderPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CouponOrderPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `coupon_order` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`ORDER_ID`':
+ $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`VALUE`':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CouponOrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getOrderId();
+ break;
+ case 2:
+ return $this->getCode();
+ break;
+ case 3:
+ return $this->getValue();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()] = true;
+ $keys = CouponOrderPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getOrderId(),
+ $keys[2] => $this->getCode(),
+ $keys[3] => $this->getValue(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrder) {
+ $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CouponOrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setOrderId($value);
+ break;
+ case 2:
+ $this->setCode($value);
+ break;
+ case 3:
+ $this->setValue($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CouponOrderPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setValue($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CouponOrderPeer::ID)) $criteria->add(CouponOrderPeer::ID, $this->id);
+ if ($this->isColumnModified(CouponOrderPeer::ORDER_ID)) $criteria->add(CouponOrderPeer::ORDER_ID, $this->order_id);
+ if ($this->isColumnModified(CouponOrderPeer::CODE)) $criteria->add(CouponOrderPeer::CODE, $this->code);
+ if ($this->isColumnModified(CouponOrderPeer::VALUE)) $criteria->add(CouponOrderPeer::VALUE, $this->value);
+ if ($this->isColumnModified(CouponOrderPeer::CREATED_AT)) $criteria->add(CouponOrderPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CouponOrderPeer::UPDATED_AT)) $criteria->add(CouponOrderPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME);
+ $criteria->add(CouponOrderPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CouponOrder (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setOrderId($this->getOrderId());
+ $copyObj->setCode($this->getCode());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CouponOrder Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CouponOrderPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CouponOrderPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Order object.
+ *
+ * @param Order $v
+ * @return CouponOrder The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrder(Order $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->order_id = null;
+ $this->code = null;
+ $this->value = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aOrder = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CouponOrderPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php b/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php
new file mode 100644
index 000000000..30b8f5429
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php
@@ -0,0 +1,1027 @@
+ array ('Id', 'OrderId', 'Code', 'Value', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'orderId', 'code', 'value', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CouponOrderPeer::ID, CouponOrderPeer::ORDER_ID, CouponOrderPeer::CODE, CouponOrderPeer::VALUE, CouponOrderPeer::CREATED_AT, CouponOrderPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ORDER_ID', 'CODE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'order_id', 'code', 'value', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CouponOrderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Value' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'orderId' => 1, 'code' => 2, 'value' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ BasePeer::TYPE_COLNAME => array (CouponOrderPeer::ID => 0, CouponOrderPeer::ORDER_ID => 1, CouponOrderPeer::CODE => 2, CouponOrderPeer::VALUE => 3, CouponOrderPeer::CREATED_AT => 4, CouponOrderPeer::UPDATED_AT => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'VALUE' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'order_id' => 1, 'code' => 2, 'value' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CouponOrderPeer::getFieldNames($toType);
+ $key = isset(CouponOrderPeer::$fieldKeys[$fromType][$name]) ? CouponOrderPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CouponOrderPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CouponOrderPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CouponOrderPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CouponOrderPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CouponOrderPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CouponOrderPeer::ID);
+ $criteria->addSelectColumn(CouponOrderPeer::ORDER_ID);
+ $criteria->addSelectColumn(CouponOrderPeer::CODE);
+ $criteria->addSelectColumn(CouponOrderPeer::VALUE);
+ $criteria->addSelectColumn(CouponOrderPeer::CREATED_AT);
+ $criteria->addSelectColumn(CouponOrderPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ORDER_ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CouponOrder
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CouponOrderPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CouponOrderPeer::populateObjects(CouponOrderPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CouponOrderPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CouponOrder $obj A CouponOrder object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CouponOrderPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CouponOrder object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CouponOrder) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CouponOrder object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CouponOrderPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CouponOrder Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CouponOrderPeer::$instances[$key])) {
+ return CouponOrderPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CouponOrderPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to coupon_order
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CouponOrderPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CouponOrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CouponOrderPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CouponOrderPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CouponOrder object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CouponOrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CouponOrderPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CouponOrderPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CouponOrderPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CouponOrderPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CouponOrderPeer::DATABASE_NAME)->getTable(CouponOrderPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCouponOrderPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCouponOrderPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CouponOrderTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CouponOrderPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CouponOrder or Criteria object.
+ *
+ * @param mixed $values Criteria or CouponOrder object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CouponOrder object
+ }
+
+ if ($criteria->containsKey(CouponOrderPeer::ID) && $criteria->keyContainsValue(CouponOrderPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponOrderPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a CouponOrder or Criteria object.
+ *
+ * @param mixed $values Criteria or CouponOrder object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CouponOrderPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CouponOrderPeer::ID);
+ $value = $criteria->remove(CouponOrderPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CouponOrderPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CouponOrderPeer::TABLE_NAME);
+ }
+
+ } else { // $values is CouponOrder object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the coupon_order table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ CouponOrderPeer::clearInstancePool();
+ CouponOrderPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CouponOrder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CouponOrder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(CouponOrderPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CouponOrderPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CouponOrder object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CouponOrder $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CouponOrderPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CouponOrderPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CouponOrderPeer::DATABASE_NAME, CouponOrderPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CouponOrder
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CouponOrderPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME);
+ $criteria->add(CouponOrderPeer::ID, $pk);
+
+ $v = CouponOrderPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return CouponOrder[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME);
+ $criteria->add(CouponOrderPeer::ID, $pks, Criteria::IN);
+ $objs = CouponOrderPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCouponOrderPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCouponOrderPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php
new file mode 100644
index 000000000..c0e40c227
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php
@@ -0,0 +1,559 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CouponOrder|CouponOrder[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CouponOrderPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CouponOrder A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `ORDER_ID`, `CODE`, `VALUE`, `CREATED_AT`, `UPDATED_AT` FROM `coupon_order` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new CouponOrder();
+ $obj->hydrate($row);
+ CouponOrderPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CouponOrder|CouponOrder[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|CouponOrder[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CouponOrderPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CouponOrderPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CouponOrderPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderId(1234); // WHERE order_id = 1234
+ * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
+ * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
+ *
+ *
+ * @see filterByOrder()
+ *
+ * @param mixed $orderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByOrderId($orderId = null, $comparison = null)
+ {
+ if (is_array($orderId)) {
+ $useMinMax = false;
+ if (isset($orderId['min'])) {
+ $this->addUsingAlias(CouponOrderPeer::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderId['max'])) {
+ $this->addUsingAlias(CouponOrderPeer::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderPeer::ORDER_ID, $orderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderPeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue(1234); // WHERE value = 1234
+ * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
+ * $query->filterByValue(array('min' => 12)); // WHERE value > 12
+ *
+ *
+ * @param mixed $value The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (is_array($value)) {
+ $useMinMax = false;
+ if (isset($value['min'])) {
+ $this->addUsingAlias(CouponOrderPeer::VALUE, $value['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($value['max'])) {
+ $this->addUsingAlias(CouponOrderPeer::VALUE, $value['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderPeer::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CouponOrderPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CouponOrderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Order object
+ *
+ * @param Order|PropelObjectCollection $order The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof Order) {
+ return $this
+ ->addUsingAlias(CouponOrderPeer::ORDER_ID, $order->getId(), $comparison);
+ } elseif ($order instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CouponOrderPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // 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, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param CouponOrder $couponOrder Object to remove from the list of results
+ *
+ * @return CouponOrderQuery The current query, for fluid interface
+ */
+ public function prune($couponOrder = null)
+ {
+ if ($couponOrder) {
+ $this->addUsingAlias(CouponOrderPeer::ID, $couponOrder->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCouponPeer.php b/core/lib/Thelia/Model/om/BaseCouponPeer.php
new file mode 100644
index 000000000..dcc446f3c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCouponPeer.php
@@ -0,0 +1,812 @@
+ array ('Id', 'Code', 'Action', 'Value', 'Used', 'AvailableSince', 'DateLimit', 'Activate', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'action', 'value', 'used', 'availableSince', 'dateLimit', 'activate', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CouponPeer::ID, CouponPeer::CODE, CouponPeer::ACTION, CouponPeer::VALUE, CouponPeer::USED, CouponPeer::AVAILABLE_SINCE, CouponPeer::DATE_LIMIT, CouponPeer::ACTIVATE, CouponPeer::CREATED_AT, CouponPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'ACTION', 'VALUE', 'USED', 'AVAILABLE_SINCE', 'DATE_LIMIT', 'ACTIVATE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'action', 'value', 'used', 'available_since', 'date_limit', 'activate', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CouponPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Action' => 2, 'Value' => 3, 'Used' => 4, 'AvailableSince' => 5, 'DateLimit' => 6, 'Activate' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'availableSince' => 5, 'dateLimit' => 6, 'activate' => 7, 'createdAt' => 8, 'updatedAt' => 9, ),
+ BasePeer::TYPE_COLNAME => array (CouponPeer::ID => 0, CouponPeer::CODE => 1, CouponPeer::ACTION => 2, CouponPeer::VALUE => 3, CouponPeer::USED => 4, CouponPeer::AVAILABLE_SINCE => 5, CouponPeer::DATE_LIMIT => 6, CouponPeer::ACTIVATE => 7, CouponPeer::CREATED_AT => 8, CouponPeer::UPDATED_AT => 9, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'ACTION' => 2, 'VALUE' => 3, 'USED' => 4, 'AVAILABLE_SINCE' => 5, 'DATE_LIMIT' => 6, 'ACTIVATE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'available_since' => 5, 'date_limit' => 6, 'activate' => 7, 'created_at' => 8, 'updated_at' => 9, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CouponPeer::getFieldNames($toType);
+ $key = isset(CouponPeer::$fieldKeys[$fromType][$name]) ? CouponPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CouponPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CouponPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CouponPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CouponPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CouponPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CouponPeer::ID);
+ $criteria->addSelectColumn(CouponPeer::CODE);
+ $criteria->addSelectColumn(CouponPeer::ACTION);
+ $criteria->addSelectColumn(CouponPeer::VALUE);
+ $criteria->addSelectColumn(CouponPeer::USED);
+ $criteria->addSelectColumn(CouponPeer::AVAILABLE_SINCE);
+ $criteria->addSelectColumn(CouponPeer::DATE_LIMIT);
+ $criteria->addSelectColumn(CouponPeer::ACTIVATE);
+ $criteria->addSelectColumn(CouponPeer::CREATED_AT);
+ $criteria->addSelectColumn(CouponPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.ACTION');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.USED');
+ $criteria->addSelectColumn($alias . '.AVAILABLE_SINCE');
+ $criteria->addSelectColumn($alias . '.DATE_LIMIT');
+ $criteria->addSelectColumn($alias . '.ACTIVATE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CouponPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Coupon
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CouponPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CouponPeer::populateObjects(CouponPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CouponPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Coupon $obj A Coupon object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CouponPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Coupon object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Coupon) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Coupon object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CouponPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Coupon Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CouponPeer::$instances[$key])) {
+ return CouponPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CouponPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to coupon
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CouponPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CouponPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CouponPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CouponPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Coupon object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CouponPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CouponPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CouponPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CouponPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CouponPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CouponPeer::DATABASE_NAME)->getTable(CouponPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCouponPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCouponPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CouponTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CouponPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Coupon or Criteria object.
+ *
+ * @param mixed $values Criteria or Coupon object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Coupon object
+ }
+
+ if ($criteria->containsKey(CouponPeer::ID) && $criteria->keyContainsValue(CouponPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Coupon or Criteria object.
+ *
+ * @param mixed $values Criteria or Coupon object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CouponPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CouponPeer::ID);
+ $value = $criteria->remove(CouponPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CouponPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CouponPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Coupon object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CouponPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the coupon table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(CouponPeer::TABLE_NAME, $con, CouponPeer::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
+ // instances get re-added by the select statement contained therein).
+ CouponPeer::clearInstancePool();
+ CouponPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Coupon or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Coupon object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ CouponPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Coupon) { // it's a model object
+ // invalidate the cache for this single object
+ CouponPeer::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(CouponPeer::DATABASE_NAME);
+ $criteria->add(CouponPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CouponPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CouponPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Coupon object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Coupon $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CouponPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CouponPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CouponPeer::DATABASE_NAME, CouponPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Coupon
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CouponPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CouponPeer::DATABASE_NAME);
+ $criteria->add(CouponPeer::ID, $pk);
+
+ $v = CouponPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Coupon[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CouponPeer::DATABASE_NAME);
+ $criteria->add(CouponPeer::ID, $pks, Criteria::IN);
+ $objs = CouponPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCouponPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCouponPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCouponQuery.php b/core/lib/Thelia/Model/om/BaseCouponQuery.php
new file mode 100644
index 000000000..267f44074
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCouponQuery.php
@@ -0,0 +1,727 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Coupon|Coupon[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CouponPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Coupon A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CODE`, `ACTION`, `VALUE`, `USED`, `AVAILABLE_SINCE`, `DATE_LIMIT`, `ACTIVATE`, `CREATED_AT`, `UPDATED_AT` FROM `coupon` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Coupon();
+ $obj->hydrate($row);
+ CouponPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Coupon|Coupon[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Coupon[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CouponPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CouponPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CouponPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the action column
+ *
+ * Example usage:
+ *
+ * $query->filterByAction('fooValue'); // WHERE action = 'fooValue'
+ * $query->filterByAction('%fooValue%'); // WHERE action LIKE '%fooValue%'
+ *
+ *
+ * @param string $action The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByAction($action = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($action)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $action)) {
+ $action = str_replace('*', '%', $action);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::ACTION, $action, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue(1234); // WHERE value = 1234
+ * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
+ * $query->filterByValue(array('min' => 12)); // WHERE value > 12
+ *
+ *
+ * @param mixed $value The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (is_array($value)) {
+ $useMinMax = false;
+ if (isset($value['min'])) {
+ $this->addUsingAlias(CouponPeer::VALUE, $value['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($value['max'])) {
+ $this->addUsingAlias(CouponPeer::VALUE, $value['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the used column
+ *
+ * Example usage:
+ *
+ * $query->filterByUsed(1234); // WHERE used = 1234
+ * $query->filterByUsed(array(12, 34)); // WHERE used IN (12, 34)
+ * $query->filterByUsed(array('min' => 12)); // WHERE used > 12
+ *
+ *
+ * @param mixed $used The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByUsed($used = null, $comparison = null)
+ {
+ if (is_array($used)) {
+ $useMinMax = false;
+ if (isset($used['min'])) {
+ $this->addUsingAlias(CouponPeer::USED, $used['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($used['max'])) {
+ $this->addUsingAlias(CouponPeer::USED, $used['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::USED, $used, $comparison);
+ }
+
+ /**
+ * Filter the query on the available_since column
+ *
+ * Example usage:
+ *
+ * $query->filterByAvailableSince('2011-03-14'); // WHERE available_since = '2011-03-14'
+ * $query->filterByAvailableSince('now'); // WHERE available_since = '2011-03-14'
+ * $query->filterByAvailableSince(array('max' => 'yesterday')); // WHERE available_since > '2011-03-13'
+ *
+ *
+ * @param mixed $availableSince The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByAvailableSince($availableSince = null, $comparison = null)
+ {
+ if (is_array($availableSince)) {
+ $useMinMax = false;
+ if (isset($availableSince['min'])) {
+ $this->addUsingAlias(CouponPeer::AVAILABLE_SINCE, $availableSince['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($availableSince['max'])) {
+ $this->addUsingAlias(CouponPeer::AVAILABLE_SINCE, $availableSince['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::AVAILABLE_SINCE, $availableSince, $comparison);
+ }
+
+ /**
+ * Filter the query on the date_limit column
+ *
+ * Example usage:
+ *
+ * $query->filterByDateLimit('2011-03-14'); // WHERE date_limit = '2011-03-14'
+ * $query->filterByDateLimit('now'); // WHERE date_limit = '2011-03-14'
+ * $query->filterByDateLimit(array('max' => 'yesterday')); // WHERE date_limit > '2011-03-13'
+ *
+ *
+ * @param mixed $dateLimit The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByDateLimit($dateLimit = null, $comparison = null)
+ {
+ if (is_array($dateLimit)) {
+ $useMinMax = false;
+ if (isset($dateLimit['min'])) {
+ $this->addUsingAlias(CouponPeer::DATE_LIMIT, $dateLimit['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dateLimit['max'])) {
+ $this->addUsingAlias(CouponPeer::DATE_LIMIT, $dateLimit['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::DATE_LIMIT, $dateLimit, $comparison);
+ }
+
+ /**
+ * Filter the query on the activate column
+ *
+ * Example usage:
+ *
+ * $query->filterByActivate(1234); // WHERE activate = 1234
+ * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34)
+ * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12
+ *
+ *
+ * @param mixed $activate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByActivate($activate = null, $comparison = null)
+ {
+ if (is_array($activate)) {
+ $useMinMax = false;
+ if (isset($activate['min'])) {
+ $this->addUsingAlias(CouponPeer::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($activate['max'])) {
+ $this->addUsingAlias(CouponPeer::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::ACTIVATE, $activate, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CouponPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CouponPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CouponPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CouponPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related CouponRule object
+ *
+ * @param CouponRule|PropelObjectCollection $couponRule the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCouponRule($couponRule, $comparison = null)
+ {
+ if ($couponRule instanceof CouponRule) {
+ return $this
+ ->addUsingAlias(CouponPeer::ID, $couponRule->getCouponId(), $comparison);
+ } elseif ($couponRule instanceof PropelObjectCollection) {
+ return $this
+ ->useCouponRuleQuery()
+ ->filterByPrimaryKeys($couponRule->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCouponRule() only accepts arguments of type CouponRule or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CouponRule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function joinCouponRule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CouponRule');
+
+ // 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, 'CouponRule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CouponRule relation CouponRule 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\CouponRuleQuery A secondary query class using the current class as primary query
+ */
+ public function useCouponRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCouponRule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CouponRule', '\Thelia\Model\CouponRuleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Coupon $coupon Object to remove from the list of results
+ *
+ * @return CouponQuery The current query, for fluid interface
+ */
+ public function prune($coupon = null)
+ {
+ if ($coupon) {
+ $this->addUsingAlias(CouponPeer::ID, $coupon->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCouponRule.php b/core/lib/Thelia/Model/om/BaseCouponRule.php
new file mode 100644
index 000000000..0a06eef8b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCouponRule.php
@@ -0,0 +1,1265 @@
+id;
+ }
+
+ /**
+ * Get the [coupon_id] column value.
+ *
+ * @return int
+ */
+ public function getCouponId()
+ {
+ return $this->coupon_id;
+ }
+
+ /**
+ * Get the [controller] column value.
+ *
+ * @return string
+ */
+ public function getController()
+ {
+ return $this->controller;
+ }
+
+ /**
+ * Get the [operation] column value.
+ *
+ * @return string
+ */
+ public function getOperation()
+ {
+ return $this->operation;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return double
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return CouponRule The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CouponRulePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [coupon_id] column.
+ *
+ * @param int $v new value
+ * @return CouponRule The current object (for fluent API support)
+ */
+ public function setCouponId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->coupon_id !== $v) {
+ $this->coupon_id = $v;
+ $this->modifiedColumns[] = CouponRulePeer::COUPON_ID;
+ }
+
+ if ($this->aCoupon !== null && $this->aCoupon->getId() !== $v) {
+ $this->aCoupon = null;
+ }
+
+
+ return $this;
+ } // setCouponId()
+
+ /**
+ * Set the value of [controller] column.
+ *
+ * @param string $v new value
+ * @return CouponRule The current object (for fluent API support)
+ */
+ public function setController($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->controller !== $v) {
+ $this->controller = $v;
+ $this->modifiedColumns[] = CouponRulePeer::CONTROLLER;
+ }
+
+
+ return $this;
+ } // setController()
+
+ /**
+ * Set the value of [operation] column.
+ *
+ * @param string $v new value
+ * @return CouponRule The current object (for fluent API support)
+ */
+ public function setOperation($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->operation !== $v) {
+ $this->operation = $v;
+ $this->modifiedColumns[] = CouponRulePeer::OPERATION;
+ }
+
+
+ return $this;
+ } // setOperation()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param double $v new value
+ * @return CouponRule The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = CouponRulePeer::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CouponRule The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CouponRulePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CouponRule The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CouponRulePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->coupon_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->controller = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->operation = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->value = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = CouponRulePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CouponRule object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aCoupon !== null && $this->coupon_id !== $this->aCoupon->getId()) {
+ $this->aCoupon = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CouponRulePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCoupon = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CouponRuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CouponRulePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CouponRulePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponRulePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CouponRulePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CouponRulePeer::COUPON_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUPON_ID`';
+ }
+ if ($this->isColumnModified(CouponRulePeer::CONTROLLER)) {
+ $modifiedColumns[':p' . $index++] = '`CONTROLLER`';
+ }
+ if ($this->isColumnModified(CouponRulePeer::OPERATION)) {
+ $modifiedColumns[':p' . $index++] = '`OPERATION`';
+ }
+ if ($this->isColumnModified(CouponRulePeer::VALUE)) {
+ $modifiedColumns[':p' . $index++] = '`VALUE`';
+ }
+ if ($this->isColumnModified(CouponRulePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CouponRulePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `coupon_rule` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`COUPON_ID`':
+ $stmt->bindValue($identifier, $this->coupon_id, PDO::PARAM_INT);
+ break;
+ case '`CONTROLLER`':
+ $stmt->bindValue($identifier, $this->controller, PDO::PARAM_STR);
+ break;
+ case '`OPERATION`':
+ $stmt->bindValue($identifier, $this->operation, PDO::PARAM_STR);
+ break;
+ case '`VALUE`':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CouponRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCouponId();
+ break;
+ case 2:
+ return $this->getController();
+ break;
+ case 3:
+ return $this->getOperation();
+ break;
+ case 4:
+ return $this->getValue();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CouponRule'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CouponRule'][$this->getPrimaryKey()] = true;
+ $keys = CouponRulePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCouponId(),
+ $keys[2] => $this->getController(),
+ $keys[3] => $this->getOperation(),
+ $keys[4] => $this->getValue(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCoupon) {
+ $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CouponRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCouponId($value);
+ break;
+ case 2:
+ $this->setController($value);
+ break;
+ case 3:
+ $this->setOperation($value);
+ break;
+ case 4:
+ $this->setValue($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CouponRulePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCouponId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setController($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setOperation($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setValue($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CouponRulePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CouponRulePeer::ID)) $criteria->add(CouponRulePeer::ID, $this->id);
+ if ($this->isColumnModified(CouponRulePeer::COUPON_ID)) $criteria->add(CouponRulePeer::COUPON_ID, $this->coupon_id);
+ if ($this->isColumnModified(CouponRulePeer::CONTROLLER)) $criteria->add(CouponRulePeer::CONTROLLER, $this->controller);
+ if ($this->isColumnModified(CouponRulePeer::OPERATION)) $criteria->add(CouponRulePeer::OPERATION, $this->operation);
+ if ($this->isColumnModified(CouponRulePeer::VALUE)) $criteria->add(CouponRulePeer::VALUE, $this->value);
+ if ($this->isColumnModified(CouponRulePeer::CREATED_AT)) $criteria->add(CouponRulePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CouponRulePeer::UPDATED_AT)) $criteria->add(CouponRulePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CouponRulePeer::DATABASE_NAME);
+ $criteria->add(CouponRulePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CouponRule (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCouponId($this->getCouponId());
+ $copyObj->setController($this->getController());
+ $copyObj->setOperation($this->getOperation());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CouponRule Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CouponRulePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CouponRulePeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Coupon object.
+ *
+ * @param Coupon $v
+ * @return CouponRule The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCoupon(Coupon $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->coupon_id = null;
+ $this->controller = null;
+ $this->operation = null;
+ $this->value = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCoupon = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CouponRulePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCouponRulePeer.php b/core/lib/Thelia/Model/om/BaseCouponRulePeer.php
new file mode 100644
index 000000000..85d9c6c0b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCouponRulePeer.php
@@ -0,0 +1,1032 @@
+ array ('Id', 'CouponId', 'Controller', 'Operation', 'Value', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'couponId', 'controller', 'operation', 'value', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CouponRulePeer::ID, CouponRulePeer::COUPON_ID, CouponRulePeer::CONTROLLER, CouponRulePeer::OPERATION, CouponRulePeer::VALUE, CouponRulePeer::CREATED_AT, CouponRulePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'COUPON_ID', 'CONTROLLER', 'OPERATION', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'coupon_id', 'controller', 'operation', 'value', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CouponRulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CouponId' => 1, 'Controller' => 2, 'Operation' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'couponId' => 1, 'controller' => 2, 'operation' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (CouponRulePeer::ID => 0, CouponRulePeer::COUPON_ID => 1, CouponRulePeer::CONTROLLER => 2, CouponRulePeer::OPERATION => 3, CouponRulePeer::VALUE => 4, CouponRulePeer::CREATED_AT => 5, CouponRulePeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'COUPON_ID' => 1, 'CONTROLLER' => 2, 'OPERATION' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'coupon_id' => 1, 'controller' => 2, 'operation' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CouponRulePeer::getFieldNames($toType);
+ $key = isset(CouponRulePeer::$fieldKeys[$fromType][$name]) ? CouponRulePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CouponRulePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CouponRulePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CouponRulePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CouponRulePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CouponRulePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CouponRulePeer::ID);
+ $criteria->addSelectColumn(CouponRulePeer::COUPON_ID);
+ $criteria->addSelectColumn(CouponRulePeer::CONTROLLER);
+ $criteria->addSelectColumn(CouponRulePeer::OPERATION);
+ $criteria->addSelectColumn(CouponRulePeer::VALUE);
+ $criteria->addSelectColumn(CouponRulePeer::CREATED_AT);
+ $criteria->addSelectColumn(CouponRulePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.COUPON_ID');
+ $criteria->addSelectColumn($alias . '.CONTROLLER');
+ $criteria->addSelectColumn($alias . '.OPERATION');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CouponRule
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CouponRulePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CouponRulePeer::populateObjects(CouponRulePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CouponRulePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CouponRule $obj A CouponRule object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CouponRulePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CouponRule object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CouponRule) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CouponRule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CouponRulePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CouponRule Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CouponRulePeer::$instances[$key])) {
+ return CouponRulePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CouponRulePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to coupon_rule
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CouponRulePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CouponRulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CouponRulePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CouponRulePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CouponRule object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CouponRulePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CouponRulePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CouponRulePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CouponRulePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CouponRulePeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CouponRulePeer::DATABASE_NAME)->getTable(CouponRulePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCouponRulePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCouponRulePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CouponRuleTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CouponRulePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CouponRule or Criteria object.
+ *
+ * @param mixed $values Criteria or CouponRule object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CouponRule object
+ }
+
+ if ($criteria->containsKey(CouponRulePeer::ID) && $criteria->keyContainsValue(CouponRulePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponRulePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a CouponRule or Criteria object.
+ *
+ * @param mixed $values Criteria or CouponRule object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CouponRulePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CouponRulePeer::ID);
+ $value = $criteria->remove(CouponRulePeer::ID);
+ if ($value) {
+ $selectCriteria->add(CouponRulePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CouponRulePeer::TABLE_NAME);
+ }
+
+ } else { // $values is CouponRule object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the coupon_rule table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ CouponRulePeer::clearInstancePool();
+ CouponRulePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CouponRule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CouponRule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(CouponRulePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CouponRulePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CouponRule object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CouponRule $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CouponRulePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CouponRulePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CouponRulePeer::DATABASE_NAME, CouponRulePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CouponRule
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CouponRulePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CouponRulePeer::DATABASE_NAME);
+ $criteria->add(CouponRulePeer::ID, $pk);
+
+ $v = CouponRulePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return CouponRule[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CouponRulePeer::DATABASE_NAME);
+ $criteria->add(CouponRulePeer::ID, $pks, Criteria::IN);
+ $objs = CouponRulePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCouponRulePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCouponRulePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php
new file mode 100644
index 000000000..39d5e507e
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php
@@ -0,0 +1,592 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CouponRule|CouponRule[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CouponRulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CouponRule A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `COUPON_ID`, `CONTROLLER`, `OPERATION`, `VALUE`, `CREATED_AT`, `UPDATED_AT` FROM `coupon_rule` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new CouponRule();
+ $obj->hydrate($row);
+ CouponRulePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CouponRule|CouponRule[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|CouponRule[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CouponRulePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CouponRulePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CouponRulePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the coupon_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCouponId(1234); // WHERE coupon_id = 1234
+ * $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
+ * $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
+ *
+ *
+ * @see filterByCoupon()
+ *
+ * @param mixed $couponId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByCouponId($couponId = null, $comparison = null)
+ {
+ if (is_array($couponId)) {
+ $useMinMax = false;
+ if (isset($couponId['min'])) {
+ $this->addUsingAlias(CouponRulePeer::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($couponId['max'])) {
+ $this->addUsingAlias(CouponRulePeer::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRulePeer::COUPON_ID, $couponId, $comparison);
+ }
+
+ /**
+ * Filter the query on the controller column
+ *
+ * Example usage:
+ *
+ * $query->filterByController('fooValue'); // WHERE controller = 'fooValue'
+ * $query->filterByController('%fooValue%'); // WHERE controller LIKE '%fooValue%'
+ *
+ *
+ * @param string $controller The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByController($controller = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($controller)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $controller)) {
+ $controller = str_replace('*', '%', $controller);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRulePeer::CONTROLLER, $controller, $comparison);
+ }
+
+ /**
+ * Filter the query on the operation column
+ *
+ * Example usage:
+ *
+ * $query->filterByOperation('fooValue'); // WHERE operation = 'fooValue'
+ * $query->filterByOperation('%fooValue%'); // WHERE operation LIKE '%fooValue%'
+ *
+ *
+ * @param string $operation The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByOperation($operation = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($operation)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $operation)) {
+ $operation = str_replace('*', '%', $operation);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRulePeer::OPERATION, $operation, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue(1234); // WHERE value = 1234
+ * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
+ * $query->filterByValue(array('min' => 12)); // WHERE value > 12
+ *
+ *
+ * @param mixed $value The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (is_array($value)) {
+ $useMinMax = false;
+ if (isset($value['min'])) {
+ $this->addUsingAlias(CouponRulePeer::VALUE, $value['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($value['max'])) {
+ $this->addUsingAlias(CouponRulePeer::VALUE, $value['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRulePeer::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CouponRulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CouponRulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRulePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CouponRulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CouponRulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRulePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Coupon object
+ *
+ * @param Coupon|PropelObjectCollection $coupon The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCoupon($coupon, $comparison = null)
+ {
+ if ($coupon instanceof Coupon) {
+ return $this
+ ->addUsingAlias(CouponRulePeer::COUPON_ID, $coupon->getId(), $comparison);
+ } elseif ($coupon instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CouponRulePeer::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCoupon() only accepts arguments of type Coupon or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Coupon relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Coupon');
+
+ // 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, 'Coupon');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Coupon relation Coupon 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\CouponQuery A secondary query class using the current class as primary query
+ */
+ public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCoupon($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param CouponRule $couponRule Object to remove from the list of results
+ *
+ * @return CouponRuleQuery The current query, for fluid interface
+ */
+ public function prune($couponRule = null)
+ {
+ if ($couponRule) {
+ $this->addUsingAlias(CouponRulePeer::ID, $couponRule->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCurrency.php b/core/lib/Thelia/Model/om/BaseCurrency.php
new file mode 100644
index 000000000..2f143f6fd
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCurrency.php
@@ -0,0 +1,1611 @@
+id;
+ }
+
+ /**
+ * Get the [name] column value.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [symbol] column value.
+ *
+ * @return string
+ */
+ public function getSymbol()
+ {
+ return $this->symbol;
+ }
+
+ /**
+ * Get the [rate] column value.
+ *
+ * @return double
+ */
+ public function getRate()
+ {
+ return $this->rate;
+ }
+
+ /**
+ * Get the [default_utility] column value.
+ *
+ * @return int
+ */
+ public function getDefaultUtility()
+ {
+ return $this->default_utility;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Currency The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CurrencyPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [name] column.
+ *
+ * @param string $v new value
+ * @return Currency The current object (for fluent API support)
+ */
+ public function setName($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->name !== $v) {
+ $this->name = $v;
+ $this->modifiedColumns[] = CurrencyPeer::NAME;
+ }
+
+
+ return $this;
+ } // setName()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return Currency The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = CurrencyPeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [symbol] column.
+ *
+ * @param string $v new value
+ * @return Currency The current object (for fluent API support)
+ */
+ public function setSymbol($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->symbol !== $v) {
+ $this->symbol = $v;
+ $this->modifiedColumns[] = CurrencyPeer::SYMBOL;
+ }
+
+
+ return $this;
+ } // setSymbol()
+
+ /**
+ * Set the value of [rate] column.
+ *
+ * @param double $v new value
+ * @return Currency The current object (for fluent API support)
+ */
+ public function setRate($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->rate !== $v) {
+ $this->rate = $v;
+ $this->modifiedColumns[] = CurrencyPeer::RATE;
+ }
+
+
+ return $this;
+ } // setRate()
+
+ /**
+ * Set the value of [default_utility] column.
+ *
+ * @param int $v new value
+ * @return Currency The current object (for fluent API support)
+ */
+ public function setDefaultUtility($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->default_utility !== $v) {
+ $this->default_utility = $v;
+ $this->modifiedColumns[] = CurrencyPeer::DEFAULT_UTILITY;
+ }
+
+
+ return $this;
+ } // setDefaultUtility()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Currency The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CurrencyPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Currency The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CurrencyPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->code = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->symbol = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->rate = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null;
+ $this->default_utility = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = CurrencyPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Currency object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CurrencyPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collOrders = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CurrencyQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CurrencyPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CurrencyPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CurrencyPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CurrencyPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CurrencyPeer::NAME)) {
+ $modifiedColumns[':p' . $index++] = '`NAME`';
+ }
+ if ($this->isColumnModified(CurrencyPeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(CurrencyPeer::SYMBOL)) {
+ $modifiedColumns[':p' . $index++] = '`SYMBOL`';
+ }
+ if ($this->isColumnModified(CurrencyPeer::RATE)) {
+ $modifiedColumns[':p' . $index++] = '`RATE`';
+ }
+ if ($this->isColumnModified(CurrencyPeer::DEFAULT_UTILITY)) {
+ $modifiedColumns[':p' . $index++] = '`DEFAULT_UTILITY`';
+ }
+ if ($this->isColumnModified(CurrencyPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CurrencyPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `currency` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`NAME`':
+ $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`SYMBOL`':
+ $stmt->bindValue($identifier, $this->symbol, PDO::PARAM_STR);
+ break;
+ case '`RATE`':
+ $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR);
+ break;
+ case '`DEFAULT_UTILITY`':
+ $stmt->bindValue($identifier, $this->default_utility, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CurrencyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getName();
+ break;
+ case 2:
+ return $this->getCode();
+ break;
+ case 3:
+ return $this->getSymbol();
+ break;
+ case 4:
+ return $this->getRate();
+ break;
+ case 5:
+ return $this->getDefaultUtility();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Currency'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Currency'][$this->getPrimaryKey()] = true;
+ $keys = CurrencyPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getName(),
+ $keys[2] => $this->getCode(),
+ $keys[3] => $this->getSymbol(),
+ $keys[4] => $this->getRate(),
+ $keys[5] => $this->getDefaultUtility(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CurrencyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setName($value);
+ break;
+ case 2:
+ $this->setCode($value);
+ break;
+ case 3:
+ $this->setSymbol($value);
+ break;
+ case 4:
+ $this->setRate($value);
+ break;
+ case 5:
+ $this->setDefaultUtility($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CurrencyPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setSymbol($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setRate($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setDefaultUtility($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CurrencyPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CurrencyPeer::ID)) $criteria->add(CurrencyPeer::ID, $this->id);
+ if ($this->isColumnModified(CurrencyPeer::NAME)) $criteria->add(CurrencyPeer::NAME, $this->name);
+ if ($this->isColumnModified(CurrencyPeer::CODE)) $criteria->add(CurrencyPeer::CODE, $this->code);
+ if ($this->isColumnModified(CurrencyPeer::SYMBOL)) $criteria->add(CurrencyPeer::SYMBOL, $this->symbol);
+ if ($this->isColumnModified(CurrencyPeer::RATE)) $criteria->add(CurrencyPeer::RATE, $this->rate);
+ if ($this->isColumnModified(CurrencyPeer::DEFAULT_UTILITY)) $criteria->add(CurrencyPeer::DEFAULT_UTILITY, $this->default_utility);
+ if ($this->isColumnModified(CurrencyPeer::CREATED_AT)) $criteria->add(CurrencyPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CurrencyPeer::UPDATED_AT)) $criteria->add(CurrencyPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CurrencyPeer::DATABASE_NAME);
+ $criteria->add(CurrencyPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Currency (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setName($this->getName());
+ $copyObj->setCode($this->getCode());
+ $copyObj->setSymbol($this->getSymbol());
+ $copyObj->setRate($this->getRate());
+ $copyObj->setDefaultUtility($this->getDefaultUtility());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Currency Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CurrencyPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CurrencyPeer();
+ }
+
+ 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.
+ *
+ * @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 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)
+ ->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 {
+ 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 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);
+ }
+
+ /**
+ * @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->setCurrency(null);
+ }
+ }
+
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->name = null;
+ $this->code = null;
+ $this->symbol = null;
+ $this->rate = null;
+ $this->default_utility = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collOrders) {
+ foreach ($this->collOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collOrders instanceof PropelCollection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CurrencyPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php
new file mode 100644
index 000000000..698b5e9e0
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php
@@ -0,0 +1,802 @@
+ array ('Id', 'Name', 'Code', 'Symbol', 'Rate', 'DefaultUtility', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'code', 'symbol', 'rate', 'defaultUtility', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CurrencyPeer::ID, CurrencyPeer::NAME, CurrencyPeer::CODE, CurrencyPeer::SYMBOL, CurrencyPeer::RATE, CurrencyPeer::DEFAULT_UTILITY, CurrencyPeer::CREATED_AT, CurrencyPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'CODE', 'SYMBOL', 'RATE', 'DEFAULT_UTILITY', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'code', 'symbol', 'rate', 'default_utility', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CurrencyPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Code' => 2, 'Symbol' => 3, 'Rate' => 4, 'DefaultUtility' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'defaultUtility' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (CurrencyPeer::ID => 0, CurrencyPeer::NAME => 1, CurrencyPeer::CODE => 2, CurrencyPeer::SYMBOL => 3, CurrencyPeer::RATE => 4, CurrencyPeer::DEFAULT_UTILITY => 5, CurrencyPeer::CREATED_AT => 6, CurrencyPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'CODE' => 2, 'SYMBOL' => 3, 'RATE' => 4, 'DEFAULT_UTILITY' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'default_utility' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CurrencyPeer::getFieldNames($toType);
+ $key = isset(CurrencyPeer::$fieldKeys[$fromType][$name]) ? CurrencyPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CurrencyPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CurrencyPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CurrencyPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CurrencyPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CurrencyPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CurrencyPeer::ID);
+ $criteria->addSelectColumn(CurrencyPeer::NAME);
+ $criteria->addSelectColumn(CurrencyPeer::CODE);
+ $criteria->addSelectColumn(CurrencyPeer::SYMBOL);
+ $criteria->addSelectColumn(CurrencyPeer::RATE);
+ $criteria->addSelectColumn(CurrencyPeer::DEFAULT_UTILITY);
+ $criteria->addSelectColumn(CurrencyPeer::CREATED_AT);
+ $criteria->addSelectColumn(CurrencyPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.NAME');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.SYMBOL');
+ $criteria->addSelectColumn($alias . '.RATE');
+ $criteria->addSelectColumn($alias . '.DEFAULT_UTILITY');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CurrencyPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Currency
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CurrencyPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CurrencyPeer::populateObjects(CurrencyPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CurrencyPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CurrencyPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Currency $obj A Currency object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CurrencyPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Currency object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Currency) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Currency object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CurrencyPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Currency Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CurrencyPeer::$instances[$key])) {
+ return CurrencyPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CurrencyPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to currency
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CurrencyPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CurrencyPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CurrencyPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CurrencyPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Currency object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CurrencyPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CurrencyPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CurrencyPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CurrencyPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CurrencyPeer::DATABASE_NAME)->getTable(CurrencyPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCurrencyPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCurrencyPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CurrencyTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CurrencyPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Currency or Criteria object.
+ *
+ * @param mixed $values Criteria or Currency object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Currency object
+ }
+
+ if ($criteria->containsKey(CurrencyPeer::ID) && $criteria->keyContainsValue(CurrencyPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CurrencyPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CurrencyPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Currency or Criteria object.
+ *
+ * @param mixed $values Criteria or Currency object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CurrencyPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CurrencyPeer::ID);
+ $value = $criteria->remove(CurrencyPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CurrencyPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CurrencyPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Currency object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CurrencyPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the currency table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(CurrencyPeer::TABLE_NAME, $con, CurrencyPeer::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
+ // instances get re-added by the select statement contained therein).
+ CurrencyPeer::clearInstancePool();
+ CurrencyPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Currency or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Currency object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ CurrencyPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Currency) { // it's a model object
+ // invalidate the cache for this single object
+ CurrencyPeer::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(CurrencyPeer::DATABASE_NAME);
+ $criteria->add(CurrencyPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CurrencyPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CurrencyPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CurrencyPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Currency object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Currency $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CurrencyPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CurrencyPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CurrencyPeer::DATABASE_NAME, CurrencyPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Currency
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CurrencyPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CurrencyPeer::DATABASE_NAME);
+ $criteria->add(CurrencyPeer::ID, $pk);
+
+ $v = CurrencyPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Currency[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CurrencyPeer::DATABASE_NAME);
+ $criteria->add(CurrencyPeer::ID, $pks, Criteria::IN);
+ $objs = CurrencyPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCurrencyPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCurrencyPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php
new file mode 100644
index 000000000..e78de4a09
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php
@@ -0,0 +1,621 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Currency|Currency[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CurrencyPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Currency A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `NAME`, `CODE`, `SYMBOL`, `RATE`, `DEFAULT_UTILITY`, `CREATED_AT`, `UPDATED_AT` FROM `currency` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Currency();
+ $obj->hydrate($row);
+ CurrencyPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Currency|Currency[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Currency[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CurrencyPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CurrencyPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CurrencyPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the name column
+ *
+ * Example usage:
+ *
+ * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
+ * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
+ *
+ *
+ * @param string $name The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterByName($name = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($name)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $name)) {
+ $name = str_replace('*', '%', $name);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyPeer::NAME, $name, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyPeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the symbol column
+ *
+ * Example usage:
+ *
+ * $query->filterBySymbol('fooValue'); // WHERE symbol = 'fooValue'
+ * $query->filterBySymbol('%fooValue%'); // WHERE symbol LIKE '%fooValue%'
+ *
+ *
+ * @param string $symbol The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterBySymbol($symbol = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($symbol)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $symbol)) {
+ $symbol = str_replace('*', '%', $symbol);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyPeer::SYMBOL, $symbol, $comparison);
+ }
+
+ /**
+ * Filter the query on the rate column
+ *
+ * Example usage:
+ *
+ * $query->filterByRate(1234); // WHERE rate = 1234
+ * $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34)
+ * $query->filterByRate(array('min' => 12)); // WHERE rate > 12
+ *
+ *
+ * @param mixed $rate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterByRate($rate = null, $comparison = null)
+ {
+ if (is_array($rate)) {
+ $useMinMax = false;
+ if (isset($rate['min'])) {
+ $this->addUsingAlias(CurrencyPeer::RATE, $rate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($rate['max'])) {
+ $this->addUsingAlias(CurrencyPeer::RATE, $rate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyPeer::RATE, $rate, $comparison);
+ }
+
+ /**
+ * Filter the query on the default_utility column
+ *
+ * Example usage:
+ *
+ * $query->filterByDefaultUtility(1234); // WHERE default_utility = 1234
+ * $query->filterByDefaultUtility(array(12, 34)); // WHERE default_utility IN (12, 34)
+ * $query->filterByDefaultUtility(array('min' => 12)); // WHERE default_utility > 12
+ *
+ *
+ * @param mixed $defaultUtility The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterByDefaultUtility($defaultUtility = null, $comparison = null)
+ {
+ if (is_array($defaultUtility)) {
+ $useMinMax = false;
+ if (isset($defaultUtility['min'])) {
+ $this->addUsingAlias(CurrencyPeer::DEFAULT_UTILITY, $defaultUtility['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($defaultUtility['max'])) {
+ $this->addUsingAlias(CurrencyPeer::DEFAULT_UTILITY, $defaultUtility['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyPeer::DEFAULT_UTILITY, $defaultUtility, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CurrencyPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CurrencyPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CurrencyPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CurrencyPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Order object
+ *
+ * @param Order|PropelObjectCollection $order the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof Order) {
+ return $this
+ ->addUsingAlias(CurrencyPeer::ID, $order->getCurrencyId(), $comparison);
+ } elseif ($order instanceof PropelObjectCollection) {
+ return $this
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // 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, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Currency $currency Object to remove from the list of results
+ *
+ * @return CurrencyQuery The current query, for fluid interface
+ */
+ public function prune($currency = null)
+ {
+ if ($currency) {
+ $this->addUsingAlias(CurrencyPeer::ID, $currency->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCustomer.php b/core/lib/Thelia/Model/om/BaseCustomer.php
new file mode 100644
index 000000000..0a9096d5f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomer.php
@@ -0,0 +1,2878 @@
+id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+ return $this->ref;
+ }
+
+ /**
+ * Get the [customer_title_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerTitleId()
+ {
+ return $this->customer_title_id;
+ }
+
+ /**
+ * Get the [company] column value.
+ *
+ * @return string
+ */
+ public function getCompany()
+ {
+ return $this->company;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+ return $this->lastname;
+ }
+
+ /**
+ * Get the [address1] column value.
+ *
+ * @return string
+ */
+ public function getAddress1()
+ {
+ return $this->address1;
+ }
+
+ /**
+ * Get the [address2] column value.
+ *
+ * @return string
+ */
+ public function getAddress2()
+ {
+ return $this->address2;
+ }
+
+ /**
+ * Get the [address3] column value.
+ *
+ * @return string
+ */
+ public function getAddress3()
+ {
+ return $this->address3;
+ }
+
+ /**
+ * Get the [zipcode] column value.
+ *
+ * @return string
+ */
+ public function getZipcode()
+ {
+ return $this->zipcode;
+ }
+
+ /**
+ * Get the [city] column value.
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+ return $this->city;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [phone] column value.
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+ return $this->phone;
+ }
+
+ /**
+ * Get the [cellphone] column value.
+ *
+ * @return string
+ */
+ public function getCellphone()
+ {
+ return $this->cellphone;
+ }
+
+ /**
+ * Get the [email] column value.
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Get the [password] column value.
+ *
+ * @return string
+ */
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ /**
+ * Get the [algo] column value.
+ *
+ * @return string
+ */
+ public function getAlgo()
+ {
+ return $this->algo;
+ }
+
+ /**
+ * Get the [salt] column value.
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+ return $this->salt;
+ }
+
+ /**
+ * Get the [reseller] column value.
+ *
+ * @return int
+ */
+ public function getReseller()
+ {
+ return $this->reseller;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [sponsor] column value.
+ *
+ * @return string
+ */
+ public function getSponsor()
+ {
+ return $this->sponsor;
+ }
+
+ /**
+ * Get the [discount] column value.
+ *
+ * @return double
+ */
+ public function getDiscount()
+ {
+ return $this->discount;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CustomerPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = CustomerPeer::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [customer_title_id] column.
+ *
+ * @param int $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setCustomerTitleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_title_id !== $v) {
+ $this->customer_title_id = $v;
+ $this->modifiedColumns[] = CustomerPeer::CUSTOMER_TITLE_ID;
+ }
+
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
+
+ return $this;
+ } // setCustomerTitleId()
+
+ /**
+ * Set the value of [company] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setCompany($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->company !== $v) {
+ $this->company = $v;
+ $this->modifiedColumns[] = CustomerPeer::COMPANY;
+ }
+
+
+ return $this;
+ } // setCompany()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[] = CustomerPeer::FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[] = CustomerPeer::LASTNAME;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [address1] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setAddress1($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address1 !== $v) {
+ $this->address1 = $v;
+ $this->modifiedColumns[] = CustomerPeer::ADDRESS1;
+ }
+
+
+ return $this;
+ } // setAddress1()
+
+ /**
+ * Set the value of [address2] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setAddress2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address2 !== $v) {
+ $this->address2 = $v;
+ $this->modifiedColumns[] = CustomerPeer::ADDRESS2;
+ }
+
+
+ return $this;
+ } // setAddress2()
+
+ /**
+ * Set the value of [address3] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setAddress3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address3 !== $v) {
+ $this->address3 = $v;
+ $this->modifiedColumns[] = CustomerPeer::ADDRESS3;
+ }
+
+
+ return $this;
+ } // setAddress3()
+
+ /**
+ * Set the value of [zipcode] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setZipcode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->zipcode !== $v) {
+ $this->zipcode = $v;
+ $this->modifiedColumns[] = CustomerPeer::ZIPCODE;
+ }
+
+
+ return $this;
+ } // setZipcode()
+
+ /**
+ * Set the value of [city] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setCity($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->city !== $v) {
+ $this->city = $v;
+ $this->modifiedColumns[] = CustomerPeer::CITY;
+ }
+
+
+ return $this;
+ } // setCity()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = CustomerPeer::COUNTRY_ID;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Set the value of [phone] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setPhone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->phone !== $v) {
+ $this->phone = $v;
+ $this->modifiedColumns[] = CustomerPeer::PHONE;
+ }
+
+
+ return $this;
+ } // setPhone()
+
+ /**
+ * Set the value of [cellphone] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setCellphone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->cellphone !== $v) {
+ $this->cellphone = $v;
+ $this->modifiedColumns[] = CustomerPeer::CELLPHONE;
+ }
+
+
+ return $this;
+ } // setCellphone()
+
+ /**
+ * Set the value of [email] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setEmail($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->email !== $v) {
+ $this->email = $v;
+ $this->modifiedColumns[] = CustomerPeer::EMAIL;
+ }
+
+
+ return $this;
+ } // setEmail()
+
+ /**
+ * Set the value of [password] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setPassword($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->password !== $v) {
+ $this->password = $v;
+ $this->modifiedColumns[] = CustomerPeer::PASSWORD;
+ }
+
+
+ return $this;
+ } // setPassword()
+
+ /**
+ * Set the value of [algo] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setAlgo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->algo !== $v) {
+ $this->algo = $v;
+ $this->modifiedColumns[] = CustomerPeer::ALGO;
+ }
+
+
+ return $this;
+ } // setAlgo()
+
+ /**
+ * Set the value of [salt] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setSalt($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->salt !== $v) {
+ $this->salt = $v;
+ $this->modifiedColumns[] = CustomerPeer::SALT;
+ }
+
+
+ return $this;
+ } // setSalt()
+
+ /**
+ * Set the value of [reseller] column.
+ *
+ * @param int $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setReseller($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->reseller !== $v) {
+ $this->reseller = $v;
+ $this->modifiedColumns[] = CustomerPeer::RESELLER;
+ }
+
+
+ return $this;
+ } // setReseller()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = CustomerPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [sponsor] column.
+ *
+ * @param string $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setSponsor($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->sponsor !== $v) {
+ $this->sponsor = $v;
+ $this->modifiedColumns[] = CustomerPeer::SPONSOR;
+ }
+
+
+ return $this;
+ } // setSponsor()
+
+ /**
+ * Set the value of [discount] column.
+ *
+ * @param double $v new value
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setDiscount($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->discount !== $v) {
+ $this->discount = $v;
+ $this->modifiedColumns[] = CustomerPeer::DISCOUNT;
+ }
+
+
+ return $this;
+ } // setDiscount()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CustomerPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Customer The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CustomerPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->ref = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->customer_title_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->company = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->firstname = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->lastname = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->address1 = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->address2 = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->address3 = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->zipcode = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
+ $this->city = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
+ $this->country_id = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
+ $this->phone = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
+ $this->cellphone = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
+ $this->email = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null;
+ $this->password = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
+ $this->algo = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
+ $this->salt = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null;
+ $this->reseller = ($row[$startcol + 18] !== null) ? (int) $row[$startcol + 18] : null;
+ $this->lang = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null;
+ $this->sponsor = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null;
+ $this->discount = ($row[$startcol + 21] !== null) ? (double) $row[$startcol + 21] : null;
+ $this->created_at = ($row[$startcol + 22] !== null) ? (string) $row[$startcol + 22] : null;
+ $this->updated_at = ($row[$startcol + 23] !== null) ? (string) $row[$startcol + 23] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 24; // 24 = CustomerPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Customer object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CustomerPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCustomerTitle = null;
+ $this->collAddresss = null;
+
+ $this->collOrders = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CustomerQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CustomerPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->addresssScheduledForDeletion !== null) {
+ if (!$this->addresssScheduledForDeletion->isEmpty()) {
+ AddressQuery::create()
+ ->filterByPrimaryKeys($this->addresssScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->addresssScheduledForDeletion = null;
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CustomerPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CustomerPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CustomerPeer::REF)) {
+ $modifiedColumns[':p' . $index++] = '`REF`';
+ }
+ if ($this->isColumnModified(CustomerPeer::CUSTOMER_TITLE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CUSTOMER_TITLE_ID`';
+ }
+ if ($this->isColumnModified(CustomerPeer::COMPANY)) {
+ $modifiedColumns[':p' . $index++] = '`COMPANY`';
+ }
+ if ($this->isColumnModified(CustomerPeer::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`FIRSTNAME`';
+ }
+ if ($this->isColumnModified(CustomerPeer::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`LASTNAME`';
+ }
+ if ($this->isColumnModified(CustomerPeer::ADDRESS1)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS1`';
+ }
+ if ($this->isColumnModified(CustomerPeer::ADDRESS2)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS2`';
+ }
+ if ($this->isColumnModified(CustomerPeer::ADDRESS3)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS3`';
+ }
+ if ($this->isColumnModified(CustomerPeer::ZIPCODE)) {
+ $modifiedColumns[':p' . $index++] = '`ZIPCODE`';
+ }
+ if ($this->isColumnModified(CustomerPeer::CITY)) {
+ $modifiedColumns[':p' . $index++] = '`CITY`';
+ }
+ if ($this->isColumnModified(CustomerPeer::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`';
+ }
+ if ($this->isColumnModified(CustomerPeer::PHONE)) {
+ $modifiedColumns[':p' . $index++] = '`PHONE`';
+ }
+ if ($this->isColumnModified(CustomerPeer::CELLPHONE)) {
+ $modifiedColumns[':p' . $index++] = '`CELLPHONE`';
+ }
+ if ($this->isColumnModified(CustomerPeer::EMAIL)) {
+ $modifiedColumns[':p' . $index++] = '`EMAIL`';
+ }
+ if ($this->isColumnModified(CustomerPeer::PASSWORD)) {
+ $modifiedColumns[':p' . $index++] = '`PASSWORD`';
+ }
+ if ($this->isColumnModified(CustomerPeer::ALGO)) {
+ $modifiedColumns[':p' . $index++] = '`ALGO`';
+ }
+ if ($this->isColumnModified(CustomerPeer::SALT)) {
+ $modifiedColumns[':p' . $index++] = '`SALT`';
+ }
+ if ($this->isColumnModified(CustomerPeer::RESELLER)) {
+ $modifiedColumns[':p' . $index++] = '`RESELLER`';
+ }
+ if ($this->isColumnModified(CustomerPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(CustomerPeer::SPONSOR)) {
+ $modifiedColumns[':p' . $index++] = '`SPONSOR`';
+ }
+ if ($this->isColumnModified(CustomerPeer::DISCOUNT)) {
+ $modifiedColumns[':p' . $index++] = '`DISCOUNT`';
+ }
+ if ($this->isColumnModified(CustomerPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CustomerPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `customer` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`REF`':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case '`CUSTOMER_TITLE_ID`':
+ $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
+ break;
+ case '`COMPANY`':
+ $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR);
+ break;
+ case '`FIRSTNAME`':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case '`LASTNAME`':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS1`':
+ $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS2`':
+ $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS3`':
+ $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
+ break;
+ case '`ZIPCODE`':
+ $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
+ break;
+ case '`CITY`':
+ $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
+ break;
+ case '`COUNTRY_ID`':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case '`PHONE`':
+ $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
+ break;
+ case '`CELLPHONE`':
+ $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR);
+ break;
+ case '`EMAIL`':
+ $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR);
+ break;
+ case '`PASSWORD`':
+ $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR);
+ break;
+ case '`ALGO`':
+ $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR);
+ break;
+ case '`SALT`':
+ $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR);
+ break;
+ case '`RESELLER`':
+ $stmt->bindValue($identifier, $this->reseller, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`SPONSOR`':
+ $stmt->bindValue($identifier, $this->sponsor, PDO::PARAM_STR);
+ break;
+ case '`DISCOUNT`':
+ $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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 = CustomerPeer::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->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CustomerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getRef();
+ break;
+ case 2:
+ return $this->getCustomerTitleId();
+ break;
+ case 3:
+ return $this->getCompany();
+ break;
+ case 4:
+ return $this->getFirstname();
+ break;
+ case 5:
+ return $this->getLastname();
+ break;
+ case 6:
+ return $this->getAddress1();
+ break;
+ case 7:
+ return $this->getAddress2();
+ break;
+ case 8:
+ return $this->getAddress3();
+ break;
+ case 9:
+ return $this->getZipcode();
+ break;
+ case 10:
+ return $this->getCity();
+ break;
+ case 11:
+ return $this->getCountryId();
+ break;
+ case 12:
+ return $this->getPhone();
+ break;
+ case 13:
+ return $this->getCellphone();
+ break;
+ case 14:
+ return $this->getEmail();
+ break;
+ case 15:
+ return $this->getPassword();
+ break;
+ case 16:
+ return $this->getAlgo();
+ break;
+ case 17:
+ return $this->getSalt();
+ break;
+ case 18:
+ return $this->getReseller();
+ break;
+ case 19:
+ return $this->getLang();
+ break;
+ case 20:
+ return $this->getSponsor();
+ break;
+ case 21:
+ return $this->getDiscount();
+ break;
+ case 22:
+ return $this->getCreatedAt();
+ break;
+ case 23:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Customer'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Customer'][$this->getPrimaryKey()] = true;
+ $keys = CustomerPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRef(),
+ $keys[2] => $this->getCustomerTitleId(),
+ $keys[3] => $this->getCompany(),
+ $keys[4] => $this->getFirstname(),
+ $keys[5] => $this->getLastname(),
+ $keys[6] => $this->getAddress1(),
+ $keys[7] => $this->getAddress2(),
+ $keys[8] => $this->getAddress3(),
+ $keys[9] => $this->getZipcode(),
+ $keys[10] => $this->getCity(),
+ $keys[11] => $this->getCountryId(),
+ $keys[12] => $this->getPhone(),
+ $keys[13] => $this->getCellphone(),
+ $keys[14] => $this->getEmail(),
+ $keys[15] => $this->getPassword(),
+ $keys[16] => $this->getAlgo(),
+ $keys[17] => $this->getSalt(),
+ $keys[18] => $this->getReseller(),
+ $keys[19] => $this->getLang(),
+ $keys[20] => $this->getSponsor(),
+ $keys[21] => $this->getDiscount(),
+ $keys[22] => $this->getCreatedAt(),
+ $keys[23] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collAddresss) {
+ $result['Addresss'] = $this->collAddresss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CustomerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setRef($value);
+ break;
+ case 2:
+ $this->setCustomerTitleId($value);
+ break;
+ case 3:
+ $this->setCompany($value);
+ break;
+ case 4:
+ $this->setFirstname($value);
+ break;
+ case 5:
+ $this->setLastname($value);
+ break;
+ case 6:
+ $this->setAddress1($value);
+ break;
+ case 7:
+ $this->setAddress2($value);
+ break;
+ case 8:
+ $this->setAddress3($value);
+ break;
+ case 9:
+ $this->setZipcode($value);
+ break;
+ case 10:
+ $this->setCity($value);
+ break;
+ case 11:
+ $this->setCountryId($value);
+ break;
+ case 12:
+ $this->setPhone($value);
+ break;
+ case 13:
+ $this->setCellphone($value);
+ break;
+ case 14:
+ $this->setEmail($value);
+ break;
+ case 15:
+ $this->setPassword($value);
+ break;
+ case 16:
+ $this->setAlgo($value);
+ break;
+ case 17:
+ $this->setSalt($value);
+ break;
+ case 18:
+ $this->setReseller($value);
+ break;
+ case 19:
+ $this->setLang($value);
+ break;
+ case 20:
+ $this->setSponsor($value);
+ break;
+ case 21:
+ $this->setDiscount($value);
+ break;
+ case 22:
+ $this->setCreatedAt($value);
+ break;
+ case 23:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CustomerPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCustomerTitleId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCompany($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setFirstname($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setLastname($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setAddress1($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setAddress2($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setAddress3($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setZipcode($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setCity($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCountryId($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setPhone($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setCellphone($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setEmail($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setPassword($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setAlgo($arr[$keys[16]]);
+ if (array_key_exists($keys[17], $arr)) $this->setSalt($arr[$keys[17]]);
+ if (array_key_exists($keys[18], $arr)) $this->setReseller($arr[$keys[18]]);
+ if (array_key_exists($keys[19], $arr)) $this->setLang($arr[$keys[19]]);
+ if (array_key_exists($keys[20], $arr)) $this->setSponsor($arr[$keys[20]]);
+ if (array_key_exists($keys[21], $arr)) $this->setDiscount($arr[$keys[21]]);
+ if (array_key_exists($keys[22], $arr)) $this->setCreatedAt($arr[$keys[22]]);
+ if (array_key_exists($keys[23], $arr)) $this->setUpdatedAt($arr[$keys[23]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CustomerPeer::ID)) $criteria->add(CustomerPeer::ID, $this->id);
+ if ($this->isColumnModified(CustomerPeer::REF)) $criteria->add(CustomerPeer::REF, $this->ref);
+ if ($this->isColumnModified(CustomerPeer::CUSTOMER_TITLE_ID)) $criteria->add(CustomerPeer::CUSTOMER_TITLE_ID, $this->customer_title_id);
+ if ($this->isColumnModified(CustomerPeer::COMPANY)) $criteria->add(CustomerPeer::COMPANY, $this->company);
+ if ($this->isColumnModified(CustomerPeer::FIRSTNAME)) $criteria->add(CustomerPeer::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(CustomerPeer::LASTNAME)) $criteria->add(CustomerPeer::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(CustomerPeer::ADDRESS1)) $criteria->add(CustomerPeer::ADDRESS1, $this->address1);
+ if ($this->isColumnModified(CustomerPeer::ADDRESS2)) $criteria->add(CustomerPeer::ADDRESS2, $this->address2);
+ if ($this->isColumnModified(CustomerPeer::ADDRESS3)) $criteria->add(CustomerPeer::ADDRESS3, $this->address3);
+ if ($this->isColumnModified(CustomerPeer::ZIPCODE)) $criteria->add(CustomerPeer::ZIPCODE, $this->zipcode);
+ if ($this->isColumnModified(CustomerPeer::CITY)) $criteria->add(CustomerPeer::CITY, $this->city);
+ if ($this->isColumnModified(CustomerPeer::COUNTRY_ID)) $criteria->add(CustomerPeer::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(CustomerPeer::PHONE)) $criteria->add(CustomerPeer::PHONE, $this->phone);
+ if ($this->isColumnModified(CustomerPeer::CELLPHONE)) $criteria->add(CustomerPeer::CELLPHONE, $this->cellphone);
+ if ($this->isColumnModified(CustomerPeer::EMAIL)) $criteria->add(CustomerPeer::EMAIL, $this->email);
+ if ($this->isColumnModified(CustomerPeer::PASSWORD)) $criteria->add(CustomerPeer::PASSWORD, $this->password);
+ if ($this->isColumnModified(CustomerPeer::ALGO)) $criteria->add(CustomerPeer::ALGO, $this->algo);
+ if ($this->isColumnModified(CustomerPeer::SALT)) $criteria->add(CustomerPeer::SALT, $this->salt);
+ if ($this->isColumnModified(CustomerPeer::RESELLER)) $criteria->add(CustomerPeer::RESELLER, $this->reseller);
+ if ($this->isColumnModified(CustomerPeer::LANG)) $criteria->add(CustomerPeer::LANG, $this->lang);
+ if ($this->isColumnModified(CustomerPeer::SPONSOR)) $criteria->add(CustomerPeer::SPONSOR, $this->sponsor);
+ if ($this->isColumnModified(CustomerPeer::DISCOUNT)) $criteria->add(CustomerPeer::DISCOUNT, $this->discount);
+ if ($this->isColumnModified(CustomerPeer::CREATED_AT)) $criteria->add(CustomerPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CustomerPeer::UPDATED_AT)) $criteria->add(CustomerPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
+ $criteria->add(CustomerPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Customer (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCustomerTitleId($this->getCustomerTitleId());
+ $copyObj->setCompany($this->getCompany());
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setAddress1($this->getAddress1());
+ $copyObj->setAddress2($this->getAddress2());
+ $copyObj->setAddress3($this->getAddress3());
+ $copyObj->setZipcode($this->getZipcode());
+ $copyObj->setCity($this->getCity());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setPhone($this->getPhone());
+ $copyObj->setCellphone($this->getCellphone());
+ $copyObj->setEmail($this->getEmail());
+ $copyObj->setPassword($this->getPassword());
+ $copyObj->setAlgo($this->getAlgo());
+ $copyObj->setSalt($this->getSalt());
+ $copyObj->setReseller($this->getReseller());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setSponsor($this->getSponsor());
+ $copyObj->setDiscount($this->getDiscount());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getAddresss() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAddress($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Customer Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CustomerPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CustomerPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a CustomerTitle object.
+ *
+ * @param CustomerTitle $v
+ * @return Customer The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomerTitle(CustomerTitle $v = null)
+ {
+ 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->addCustomer($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->addCustomers($this);
+ */
+ }
+
+ return $this->aCustomerTitle;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Address' == $relationName) {
+ $this->initAddresss();
+ }
+ if ('Order' == $relationName) {
+ $this->initOrders();
+ }
+ }
+
+ /**
+ * 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 PropelObjectCollection|Address[] List of Address objects
+ * @throws PropelException
+ */
+ 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);
+
+ 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->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 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
+ ->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->ref = null;
+ $this->customer_title_id = null;
+ $this->company = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->address1 = null;
+ $this->address2 = null;
+ $this->address3 = null;
+ $this->zipcode = null;
+ $this->city = null;
+ $this->country_id = null;
+ $this->phone = null;
+ $this->cellphone = null;
+ $this->email = null;
+ $this->password = null;
+ $this->algo = null;
+ $this->salt = null;
+ $this->reseller = null;
+ $this->lang = null;
+ $this->sponsor = null;
+ $this->discount = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($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->collAddresss instanceof PropelCollection) {
+ $this->collAddresss->clearIterator();
+ }
+ $this->collAddresss = null;
+ if ($this->collOrders instanceof PropelCollection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
+ $this->aCustomerTitle = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CustomerPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCustomerPeer.php b/core/lib/Thelia/Model/om/BaseCustomerPeer.php
new file mode 100644
index 000000000..75448e400
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomerPeer.php
@@ -0,0 +1,1125 @@
+ array ('Id', 'Ref', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'Email', 'Password', 'Algo', 'Salt', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'ref', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CustomerPeer::ID, CustomerPeer::REF, CustomerPeer::CUSTOMER_TITLE_ID, CustomerPeer::COMPANY, CustomerPeer::FIRSTNAME, CustomerPeer::LASTNAME, CustomerPeer::ADDRESS1, CustomerPeer::ADDRESS2, CustomerPeer::ADDRESS3, CustomerPeer::ZIPCODE, CustomerPeer::CITY, CustomerPeer::COUNTRY_ID, CustomerPeer::PHONE, CustomerPeer::CELLPHONE, CustomerPeer::EMAIL, CustomerPeer::PASSWORD, CustomerPeer::ALGO, CustomerPeer::SALT, CustomerPeer::RESELLER, CustomerPeer::LANG, CustomerPeer::SPONSOR, CustomerPeer::DISCOUNT, CustomerPeer::CREATED_AT, CustomerPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'REF', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'EMAIL', 'PASSWORD', 'ALGO', 'SALT', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'ref', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CustomerPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Ref' => 1, 'CustomerTitleId' => 2, 'Company' => 3, 'Firstname' => 4, 'Lastname' => 5, 'Address1' => 6, 'Address2' => 7, 'Address3' => 8, 'Zipcode' => 9, 'City' => 10, 'CountryId' => 11, 'Phone' => 12, 'Cellphone' => 13, 'Email' => 14, 'Password' => 15, 'Algo' => 16, 'Salt' => 17, 'Reseller' => 18, 'Lang' => 19, 'Sponsor' => 20, 'Discount' => 21, 'CreatedAt' => 22, 'UpdatedAt' => 23, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'ref' => 1, 'customerTitleId' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'countryId' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'createdAt' => 22, 'updatedAt' => 23, ),
+ BasePeer::TYPE_COLNAME => array (CustomerPeer::ID => 0, CustomerPeer::REF => 1, CustomerPeer::CUSTOMER_TITLE_ID => 2, CustomerPeer::COMPANY => 3, CustomerPeer::FIRSTNAME => 4, CustomerPeer::LASTNAME => 5, CustomerPeer::ADDRESS1 => 6, CustomerPeer::ADDRESS2 => 7, CustomerPeer::ADDRESS3 => 8, CustomerPeer::ZIPCODE => 9, CustomerPeer::CITY => 10, CustomerPeer::COUNTRY_ID => 11, CustomerPeer::PHONE => 12, CustomerPeer::CELLPHONE => 13, CustomerPeer::EMAIL => 14, CustomerPeer::PASSWORD => 15, CustomerPeer::ALGO => 16, CustomerPeer::SALT => 17, CustomerPeer::RESELLER => 18, CustomerPeer::LANG => 19, CustomerPeer::SPONSOR => 20, CustomerPeer::DISCOUNT => 21, CustomerPeer::CREATED_AT => 22, CustomerPeer::UPDATED_AT => 23, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'REF' => 1, 'CUSTOMER_TITLE_ID' => 2, 'COMPANY' => 3, 'FIRSTNAME' => 4, 'LASTNAME' => 5, 'ADDRESS1' => 6, 'ADDRESS2' => 7, 'ADDRESS3' => 8, 'ZIPCODE' => 9, 'CITY' => 10, 'COUNTRY_ID' => 11, 'PHONE' => 12, 'CELLPHONE' => 13, 'EMAIL' => 14, 'PASSWORD' => 15, 'ALGO' => 16, 'SALT' => 17, 'RESELLER' => 18, 'LANG' => 19, 'SPONSOR' => 20, 'DISCOUNT' => 21, 'CREATED_AT' => 22, 'UPDATED_AT' => 23, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'ref' => 1, 'customer_title_id' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'country_id' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'created_at' => 22, 'updated_at' => 23, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CustomerPeer::getFieldNames($toType);
+ $key = isset(CustomerPeer::$fieldKeys[$fromType][$name]) ? CustomerPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CustomerPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CustomerPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CustomerPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CustomerPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CustomerPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CustomerPeer::ID);
+ $criteria->addSelectColumn(CustomerPeer::REF);
+ $criteria->addSelectColumn(CustomerPeer::CUSTOMER_TITLE_ID);
+ $criteria->addSelectColumn(CustomerPeer::COMPANY);
+ $criteria->addSelectColumn(CustomerPeer::FIRSTNAME);
+ $criteria->addSelectColumn(CustomerPeer::LASTNAME);
+ $criteria->addSelectColumn(CustomerPeer::ADDRESS1);
+ $criteria->addSelectColumn(CustomerPeer::ADDRESS2);
+ $criteria->addSelectColumn(CustomerPeer::ADDRESS3);
+ $criteria->addSelectColumn(CustomerPeer::ZIPCODE);
+ $criteria->addSelectColumn(CustomerPeer::CITY);
+ $criteria->addSelectColumn(CustomerPeer::COUNTRY_ID);
+ $criteria->addSelectColumn(CustomerPeer::PHONE);
+ $criteria->addSelectColumn(CustomerPeer::CELLPHONE);
+ $criteria->addSelectColumn(CustomerPeer::EMAIL);
+ $criteria->addSelectColumn(CustomerPeer::PASSWORD);
+ $criteria->addSelectColumn(CustomerPeer::ALGO);
+ $criteria->addSelectColumn(CustomerPeer::SALT);
+ $criteria->addSelectColumn(CustomerPeer::RESELLER);
+ $criteria->addSelectColumn(CustomerPeer::LANG);
+ $criteria->addSelectColumn(CustomerPeer::SPONSOR);
+ $criteria->addSelectColumn(CustomerPeer::DISCOUNT);
+ $criteria->addSelectColumn(CustomerPeer::CREATED_AT);
+ $criteria->addSelectColumn(CustomerPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
+ $criteria->addSelectColumn($alias . '.COMPANY');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.ADDRESS1');
+ $criteria->addSelectColumn($alias . '.ADDRESS2');
+ $criteria->addSelectColumn($alias . '.ADDRESS3');
+ $criteria->addSelectColumn($alias . '.ZIPCODE');
+ $criteria->addSelectColumn($alias . '.CITY');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.PHONE');
+ $criteria->addSelectColumn($alias . '.CELLPHONE');
+ $criteria->addSelectColumn($alias . '.EMAIL');
+ $criteria->addSelectColumn($alias . '.PASSWORD');
+ $criteria->addSelectColumn($alias . '.ALGO');
+ $criteria->addSelectColumn($alias . '.SALT');
+ $criteria->addSelectColumn($alias . '.RESELLER');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.SPONSOR');
+ $criteria->addSelectColumn($alias . '.DISCOUNT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CustomerPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Customer
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CustomerPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CustomerPeer::populateObjects(CustomerPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CustomerPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Customer $obj A Customer object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CustomerPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Customer object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Customer) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Customer object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CustomerPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Customer Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CustomerPeer::$instances[$key])) {
+ return CustomerPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CustomerPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to customer
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in AddressPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CustomerPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CustomerPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CustomerPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Customer object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CustomerPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CustomerPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CustomerPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CustomerPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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(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::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 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
+ * @return array Array of Customer 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(CustomerPeer::DATABASE_NAME);
+ }
+
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol = CustomerPeer::NUM_HYDRATE_COLUMNS;
+ CustomerTitlePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::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 = 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 (Customer) to $obj2 (CustomerTitle)
+ $obj2->addCustomer($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(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::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 Customer 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 Customer 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(CustomerPeer::DATABASE_NAME);
+ }
+
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol2 = CustomerPeer::NUM_HYDRATE_COLUMNS;
+
+ CustomerTitlePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::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 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 (Customer) to the collection in $obj2 (CustomerTitle)
+ $obj2->addCustomer($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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CustomerPeer::DATABASE_NAME)->getTable(CustomerPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCustomerPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCustomerPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CustomerTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CustomerPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Customer or Criteria object.
+ *
+ * @param mixed $values Criteria or Customer object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Customer object
+ }
+
+ if ($criteria->containsKey(CustomerPeer::ID) && $criteria->keyContainsValue(CustomerPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Customer or Criteria object.
+ *
+ * @param mixed $values Criteria or Customer object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CustomerPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CustomerPeer::ID);
+ $value = $criteria->remove(CustomerPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CustomerPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Customer object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CustomerPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the customer table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ CustomerPeer::clearInstancePool();
+ CustomerPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Customer or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Customer object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(CustomerPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CustomerPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Customer object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Customer $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CustomerPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CustomerPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CustomerPeer::DATABASE_NAME, CustomerPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Customer
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CustomerPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
+ $criteria->add(CustomerPeer::ID, $pk);
+
+ $v = CustomerPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Customer[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
+ $criteria->add(CustomerPeer::ID, $pks, Criteria::IN);
+ $objs = CustomerPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCustomerPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCustomerPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCustomerQuery.php b/core/lib/Thelia/Model/om/BaseCustomerQuery.php
new file mode 100644
index 000000000..39b21ba14
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomerQuery.php
@@ -0,0 +1,1335 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Customer|Customer[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CustomerPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Customer A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `REF`, `CUSTOMER_TITLE_ID`, `COMPANY`, `FIRSTNAME`, `LASTNAME`, `ADDRESS1`, `ADDRESS2`, `ADDRESS3`, `ZIPCODE`, `CITY`, `COUNTRY_ID`, `PHONE`, `CELLPHONE`, `EMAIL`, `PASSWORD`, `ALGO`, `SALT`, `RESELLER`, `LANG`, `SPONSOR`, `DISCOUNT`, `CREATED_AT`, `UPDATED_AT` FROM `customer` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Customer();
+ $obj->hydrate($row);
+ CustomerPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Customer|Customer[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Customer[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CustomerPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CustomerPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CustomerPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_title_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
+ * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
+ * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
+ *
+ *
+ * @see filterByCustomerTitle()
+ *
+ * @param mixed $customerTitleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
+ {
+ if (is_array($customerTitleId)) {
+ $useMinMax = false;
+ if (isset($customerTitleId['min'])) {
+ $this->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerTitleId['max'])) {
+ $this->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the company column
+ *
+ * Example usage:
+ *
+ * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue'
+ * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
+ *
+ *
+ * @param string $company The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByCompany($company = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($company)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $company)) {
+ $company = str_replace('*', '%', $company);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::COMPANY, $company, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the address1 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue'
+ * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address1 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByAddress1($address1 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address1)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address1)) {
+ $address1 = str_replace('*', '%', $address1);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::ADDRESS1, $address1, $comparison);
+ }
+
+ /**
+ * Filter the query on the address2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue'
+ * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address2 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByAddress2($address2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address2)) {
+ $address2 = str_replace('*', '%', $address2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::ADDRESS2, $address2, $comparison);
+ }
+
+ /**
+ * Filter the query on the address3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue'
+ * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address3 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByAddress3($address3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address3)) {
+ $address3 = str_replace('*', '%', $address3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::ADDRESS3, $address3, $comparison);
+ }
+
+ /**
+ * Filter the query on the zipcode column
+ *
+ * Example usage:
+ *
+ * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue'
+ * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
+ *
+ *
+ * @param string $zipcode The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByZipcode($zipcode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($zipcode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $zipcode)) {
+ $zipcode = str_replace('*', '%', $zipcode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::ZIPCODE, $zipcode, $comparison);
+ }
+
+ /**
+ * Filter the query on the city column
+ *
+ * Example usage:
+ *
+ * $query->filterByCity('fooValue'); // WHERE city = 'fooValue'
+ * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
+ *
+ *
+ * @param string $city The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByCity($city = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($city)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $city)) {
+ $city = str_replace('*', '%', $city);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::CITY, $city, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the phone column
+ *
+ * Example usage:
+ *
+ * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
+ * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
+ *
+ *
+ * @param string $phone The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByPhone($phone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($phone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $phone)) {
+ $phone = str_replace('*', '%', $phone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::PHONE, $phone, $comparison);
+ }
+
+ /**
+ * Filter the query on the cellphone column
+ *
+ * Example usage:
+ *
+ * $query->filterByCellphone('fooValue'); // WHERE cellphone = 'fooValue'
+ * $query->filterByCellphone('%fooValue%'); // WHERE cellphone LIKE '%fooValue%'
+ *
+ *
+ * @param string $cellphone The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByCellphone($cellphone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($cellphone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $cellphone)) {
+ $cellphone = str_replace('*', '%', $cellphone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::CELLPHONE, $cellphone, $comparison);
+ }
+
+ /**
+ * Filter the query on the email column
+ *
+ * Example usage:
+ *
+ * $query->filterByEmail('fooValue'); // WHERE email = 'fooValue'
+ * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
+ *
+ *
+ * @param string $email The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByEmail($email = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($email)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $email)) {
+ $email = str_replace('*', '%', $email);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::EMAIL, $email, $comparison);
+ }
+
+ /**
+ * Filter the query on the password column
+ *
+ * Example usage:
+ *
+ * $query->filterByPassword('fooValue'); // WHERE password = 'fooValue'
+ * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%'
+ *
+ *
+ * @param string $password The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByPassword($password = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($password)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $password)) {
+ $password = str_replace('*', '%', $password);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::PASSWORD, $password, $comparison);
+ }
+
+ /**
+ * Filter the query on the algo column
+ *
+ * Example usage:
+ *
+ * $query->filterByAlgo('fooValue'); // WHERE algo = 'fooValue'
+ * $query->filterByAlgo('%fooValue%'); // WHERE algo LIKE '%fooValue%'
+ *
+ *
+ * @param string $algo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByAlgo($algo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($algo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $algo)) {
+ $algo = str_replace('*', '%', $algo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::ALGO, $algo, $comparison);
+ }
+
+ /**
+ * Filter the query on the salt column
+ *
+ * Example usage:
+ *
+ * $query->filterBySalt('fooValue'); // WHERE salt = 'fooValue'
+ * $query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%'
+ *
+ *
+ * @param string $salt The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterBySalt($salt = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($salt)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $salt)) {
+ $salt = str_replace('*', '%', $salt);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::SALT, $salt, $comparison);
+ }
+
+ /**
+ * Filter the query on the reseller column
+ *
+ * Example usage:
+ *
+ * $query->filterByReseller(1234); // WHERE reseller = 1234
+ * $query->filterByReseller(array(12, 34)); // WHERE reseller IN (12, 34)
+ * $query->filterByReseller(array('min' => 12)); // WHERE reseller > 12
+ *
+ *
+ * @param mixed $reseller The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByReseller($reseller = null, $comparison = null)
+ {
+ if (is_array($reseller)) {
+ $useMinMax = false;
+ if (isset($reseller['min'])) {
+ $this->addUsingAlias(CustomerPeer::RESELLER, $reseller['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($reseller['max'])) {
+ $this->addUsingAlias(CustomerPeer::RESELLER, $reseller['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::RESELLER, $reseller, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the sponsor column
+ *
+ * Example usage:
+ *
+ * $query->filterBySponsor('fooValue'); // WHERE sponsor = 'fooValue'
+ * $query->filterBySponsor('%fooValue%'); // WHERE sponsor LIKE '%fooValue%'
+ *
+ *
+ * @param string $sponsor The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterBySponsor($sponsor = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($sponsor)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $sponsor)) {
+ $sponsor = str_replace('*', '%', $sponsor);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::SPONSOR, $sponsor, $comparison);
+ }
+
+ /**
+ * Filter the query on the discount column
+ *
+ * Example usage:
+ *
+ * $query->filterByDiscount(1234); // WHERE discount = 1234
+ * $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34)
+ * $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12
+ *
+ *
+ * @param mixed $discount The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByDiscount($discount = null, $comparison = null)
+ {
+ if (is_array($discount)) {
+ $useMinMax = false;
+ if (isset($discount['min'])) {
+ $this->addUsingAlias(CustomerPeer::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($discount['max'])) {
+ $this->addUsingAlias(CustomerPeer::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::DISCOUNT, $discount, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CustomerPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CustomerPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CustomerPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CustomerPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ 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 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 filterByAddress($address, $comparison = null)
+ {
+ if ($address instanceof Address) {
+ return $this
+ ->addUsingAlias(CustomerPeer::ID, $address->getCustomerId(), $comparison);
+ } elseif ($address instanceof PropelObjectCollection) {
+ return $this
+ ->useAddressQuery()
+ ->filterByPrimaryKeys($address->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Address relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Address');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Address');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Address relation Address object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query
+ */
+ public function useAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAddress($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
+ }
+
+ /**
+ * Filter the query by a related Order object
+ *
+ * @param Order|PropelObjectCollection $order the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof Order) {
+ return $this
+ ->addUsingAlias(CustomerPeer::ID, $order->getCustomerId(), $comparison);
+ } elseif ($order instanceof PropelObjectCollection) {
+ return $this
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order 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 joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // 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, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Customer $customer Object to remove from the list of results
+ *
+ * @return CustomerQuery The current query, for fluid interface
+ */
+ public function prune($customer = null)
+ {
+ if ($customer) {
+ $this->addUsingAlias(CustomerPeer::ID, $customer->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitle.php b/core/lib/Thelia/Model/om/BaseCustomerTitle.php
new file mode 100644
index 000000000..6a91ebd96
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitle.php
@@ -0,0 +1,1937 @@
+default_utility = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseCustomerTitle object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Get the [default_utility] column value.
+ *
+ * @return int
+ */
+ public function getDefaultUtility()
+ {
+ return $this->default_utility;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return string
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return CustomerTitle The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CustomerTitlePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [default_utility] column.
+ *
+ * @param int $v new value
+ * @return CustomerTitle The current object (for fluent API support)
+ */
+ public function setDefaultUtility($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->default_utility !== $v) {
+ $this->default_utility = $v;
+ $this->modifiedColumns[] = CustomerTitlePeer::DEFAULT_UTILITY;
+ }
+
+
+ return $this;
+ } // setDefaultUtility()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param string $v new value
+ * @return CustomerTitle The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = CustomerTitlePeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CustomerTitle The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CustomerTitlePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CustomerTitle The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CustomerTitlePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->default_utility !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->default_utility = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->position = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = CustomerTitlePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CustomerTitle object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CustomerTitlePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAddresss = null;
+
+ $this->collCustomers = null;
+
+ $this->collCustomerTitleDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CustomerTitleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CustomerTitlePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CustomerTitlePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerTitlePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CustomerTitlePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CustomerTitlePeer::DEFAULT_UTILITY)) {
+ $modifiedColumns[':p' . $index++] = '`DEFAULT_UTILITY`';
+ }
+ if ($this->isColumnModified(CustomerTitlePeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(CustomerTitlePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `customer_title` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`DEFAULT_UTILITY`':
+ $stmt->bindValue($identifier, $this->default_utility, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CustomerTitlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getDefaultUtility();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CustomerTitle'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CustomerTitle'][$this->getPrimaryKey()] = true;
+ $keys = CustomerTitlePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getDefaultUtility(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collAddresss) {
+ $result['Addresss'] = $this->collAddresss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCustomers) {
+ $result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCustomerTitleDescs) {
+ $result['CustomerTitleDescs'] = $this->collCustomerTitleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CustomerTitlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setDefaultUtility($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CustomerTitlePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setDefaultUtility($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CustomerTitlePeer::ID)) $criteria->add(CustomerTitlePeer::ID, $this->id);
+ if ($this->isColumnModified(CustomerTitlePeer::DEFAULT_UTILITY)) $criteria->add(CustomerTitlePeer::DEFAULT_UTILITY, $this->default_utility);
+ if ($this->isColumnModified(CustomerTitlePeer::POSITION)) $criteria->add(CustomerTitlePeer::POSITION, $this->position);
+ if ($this->isColumnModified(CustomerTitlePeer::CREATED_AT)) $criteria->add(CustomerTitlePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) $criteria->add(CustomerTitlePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME);
+ $criteria->add(CustomerTitlePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CustomerTitle (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setDefaultUtility($this->getDefaultUtility());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getAddresss() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAddress($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCustomers() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCustomer($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CustomerTitle Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CustomerTitlePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CustomerTitlePeer();
+ }
+
+ 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.
+ *
+ * @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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param Address $address The address object to add.
+ */
+ protected function doAddAddress($address)
+ {
+ $this->collAddresss[]= $address;
+ $address->setCustomerTitle($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->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.
+ *
+ * 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 getCustomers($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collCustomersPartial && !$this->isNew();
+ if (null === $this->collCustomers || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCustomers) {
+ // return empty collection
+ $this->initCustomers();
+ } else {
+ $collCustomers = CustomerQuery::create(null, $criteria)
+ ->filterByCustomerTitle($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCustomersPartial && count($collCustomers)) {
+ $this->initCustomers(false);
+
+ foreach($collCustomers as $obj) {
+ if (false == $this->collCustomers->contains($obj)) {
+ $this->collCustomers->append($obj);
+ }
+ }
+
+ $this->collCustomersPartial = true;
+ }
+
+ return $collCustomers;
+ }
+
+ if($partial && $this->collCustomers) {
+ foreach($this->collCustomers as $obj) {
+ if($obj->isNew()) {
+ $collCustomers[] = $obj;
+ }
+ }
+ }
+
+ $this->collCustomers = $collCustomers;
+ $this->collCustomersPartial = false;
+ }
+ }
+
+ return $this->collCustomers;
+ }
+
+ /**
+ * Sets a collection of Customer objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $customers A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setCustomers(PropelCollection $customers, PropelPDO $con = null)
+ {
+ $this->customersScheduledForDeletion = $this->getCustomers(new Criteria(), $con)->diff($customers);
+
+ foreach ($this->customersScheduledForDeletion as $customerRemoved) {
+ $customerRemoved->setCustomerTitle(null);
+ }
+
+ $this->collCustomers = null;
+ foreach ($customers as $customer) {
+ $this->addCustomer($customer);
+ }
+
+ $this->collCustomers = $customers;
+ $this->collCustomersPartial = false;
+ }
+
+ /**
+ * Returns the number of related Customer objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Customer objects.
+ * @throws PropelException
+ */
+ public function countCustomers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCustomersPartial && !$this->isNew();
+ if (null === $this->collCustomers || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCustomers) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getCustomers());
+ }
+ $query = CustomerQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomerTitle($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCustomers);
+ }
+ }
+
+ /**
+ * Method called to associate a Customer object to this object
+ * through the Customer foreign key attribute.
+ *
+ * @param Customer $l Customer
+ * @return CustomerTitle The current object (for fluent API support)
+ */
+ public function addCustomer(Customer $l)
+ {
+ if ($this->collCustomers === null) {
+ $this->initCustomers();
+ $this->collCustomersPartial = true;
+ }
+ if (!$this->collCustomers->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddCustomer($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Customer $customer The customer object to add.
+ */
+ protected function doAddCustomer($customer)
+ {
+ $this->collCustomers[]= $customer;
+ $customer->setCustomerTitle($this);
+ }
+
+ /**
+ * @param Customer $customer The customer object to remove.
+ */
+ public function removeCustomer($customer)
+ {
+ if ($this->getCustomers()->contains($customer)) {
+ $this->collCustomers->remove($this->collCustomers->search($customer));
+ if (null === $this->customersScheduledForDeletion) {
+ $this->customersScheduledForDeletion = clone $this->collCustomers;
+ $this->customersScheduledForDeletion->clear();
+ }
+ $this->customersScheduledForDeletion[]= $customer;
+ $customer->setCustomerTitle(null);
+ }
+ }
+
+ /**
+ * Clears out the collCustomerTitleDescs collection
+ *
+ * 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 getCustomerTitleDescs($criteria = null, PropelPDO $con = 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 {
+ return count($this->collCustomerTitleDescs);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * @param CustomerTitleDesc $customerTitleDesc The customerTitleDesc object to remove.
+ */
+ public function removeCustomerTitleDesc($customerTitleDesc)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->default_utility = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ 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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CustomerTitlePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php b/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php
new file mode 100644
index 000000000..e73e04c23
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php
@@ -0,0 +1,1265 @@
+id;
+ }
+
+ /**
+ * Get the [customer_title_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerTitleId()
+ {
+ return $this->customer_title_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [short] column value.
+ *
+ * @return string
+ */
+ public function getShort()
+ {
+ return $this->short;
+ }
+
+ /**
+ * Get the [long] column value.
+ *
+ * @return string
+ */
+ public function getLong()
+ {
+ return $this->long;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return CustomerTitleDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CustomerTitleDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [customer_title_id] column.
+ *
+ * @param int $v new value
+ * @return CustomerTitleDesc The current object (for fluent API support)
+ */
+ public function setCustomerTitleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_title_id !== $v) {
+ $this->customer_title_id = $v;
+ $this->modifiedColumns[] = CustomerTitleDescPeer::CUSTOMER_TITLE_ID;
+ }
+
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
+
+ return $this;
+ } // setCustomerTitleId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return CustomerTitleDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = CustomerTitleDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [short] column.
+ *
+ * @param string $v new value
+ * @return CustomerTitleDesc The current object (for fluent API support)
+ */
+ public function setShort($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->short !== $v) {
+ $this->short = $v;
+ $this->modifiedColumns[] = CustomerTitleDescPeer::SHORT;
+ }
+
+
+ return $this;
+ } // setShort()
+
+ /**
+ * Set the value of [long] column.
+ *
+ * @param string $v new value
+ * @return CustomerTitleDesc The current object (for fluent API support)
+ */
+ public function setLong($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->long !== $v) {
+ $this->long = $v;
+ $this->modifiedColumns[] = CustomerTitleDescPeer::LONG;
+ }
+
+
+ return $this;
+ } // setLong()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CustomerTitleDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = CustomerTitleDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CustomerTitleDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = CustomerTitleDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->customer_title_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->short = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->long = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = CustomerTitleDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CustomerTitleDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CustomerTitleDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCustomerTitle = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CustomerTitleDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CustomerTitleDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CustomerTitleDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerTitleDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CustomerTitleDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CustomerTitleDescPeer::CUSTOMER_TITLE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CUSTOMER_TITLE_ID`';
+ }
+ if ($this->isColumnModified(CustomerTitleDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(CustomerTitleDescPeer::SHORT)) {
+ $modifiedColumns[':p' . $index++] = '`SHORT`';
+ }
+ if ($this->isColumnModified(CustomerTitleDescPeer::LONG)) {
+ $modifiedColumns[':p' . $index++] = '`LONG`';
+ }
+ if ($this->isColumnModified(CustomerTitleDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CustomerTitleDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `customer_title_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CUSTOMER_TITLE_ID`':
+ $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`SHORT`':
+ $stmt->bindValue($identifier, $this->short, PDO::PARAM_STR);
+ break;
+ case '`LONG`':
+ $stmt->bindValue($identifier, $this->long, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CustomerTitleDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCustomerTitleId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getShort();
+ break;
+ case 4:
+ return $this->getLong();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CustomerTitleDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CustomerTitleDesc'][$this->getPrimaryKey()] = true;
+ $keys = CustomerTitleDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCustomerTitleId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getShort(),
+ $keys[4] => $this->getLong(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CustomerTitleDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCustomerTitleId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setShort($value);
+ break;
+ case 4:
+ $this->setLong($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CustomerTitleDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCustomerTitleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setShort($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setLong($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CustomerTitleDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CustomerTitleDescPeer::ID)) $criteria->add(CustomerTitleDescPeer::ID, $this->id);
+ if ($this->isColumnModified(CustomerTitleDescPeer::CUSTOMER_TITLE_ID)) $criteria->add(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $this->customer_title_id);
+ if ($this->isColumnModified(CustomerTitleDescPeer::LANG)) $criteria->add(CustomerTitleDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(CustomerTitleDescPeer::SHORT)) $criteria->add(CustomerTitleDescPeer::SHORT, $this->short);
+ if ($this->isColumnModified(CustomerTitleDescPeer::LONG)) $criteria->add(CustomerTitleDescPeer::LONG, $this->long);
+ if ($this->isColumnModified(CustomerTitleDescPeer::CREATED_AT)) $criteria->add(CustomerTitleDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CustomerTitleDescPeer::UPDATED_AT)) $criteria->add(CustomerTitleDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CustomerTitleDescPeer::DATABASE_NAME);
+ $criteria->add(CustomerTitleDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CustomerTitleDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCustomerTitleId($this->getCustomerTitleId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setShort($this->getShort());
+ $copyObj->setLong($this->getLong());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CustomerTitleDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CustomerTitleDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CustomerTitleDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a CustomerTitle object.
+ *
+ * @param CustomerTitle $v
+ * @return CustomerTitleDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomerTitle(CustomerTitle $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->customer_title_id = null;
+ $this->lang = null;
+ $this->short = null;
+ $this->long = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCustomerTitle = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CustomerTitleDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleDescPeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitleDescPeer.php
new file mode 100644
index 000000000..0f5f901aa
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitleDescPeer.php
@@ -0,0 +1,1032 @@
+ array ('Id', 'CustomerTitleId', 'Lang', 'Short', 'Long', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'customerTitleId', 'lang', 'short', 'long', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CustomerTitleDescPeer::ID, CustomerTitleDescPeer::CUSTOMER_TITLE_ID, CustomerTitleDescPeer::LANG, CustomerTitleDescPeer::SHORT, CustomerTitleDescPeer::LONG, CustomerTitleDescPeer::CREATED_AT, CustomerTitleDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CUSTOMER_TITLE_ID', 'LANG', 'SHORT', 'LONG', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'customer_title_id', 'lang', 'short', 'long', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CustomerTitleDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CustomerTitleId' => 1, 'Lang' => 2, 'Short' => 3, 'Long' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'customerTitleId' => 1, 'lang' => 2, 'short' => 3, 'long' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (CustomerTitleDescPeer::ID => 0, CustomerTitleDescPeer::CUSTOMER_TITLE_ID => 1, CustomerTitleDescPeer::LANG => 2, CustomerTitleDescPeer::SHORT => 3, CustomerTitleDescPeer::LONG => 4, CustomerTitleDescPeer::CREATED_AT => 5, CustomerTitleDescPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CUSTOMER_TITLE_ID' => 1, 'LANG' => 2, 'SHORT' => 3, 'LONG' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'customer_title_id' => 1, 'lang' => 2, 'short' => 3, 'long' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CustomerTitleDescPeer::getFieldNames($toType);
+ $key = isset(CustomerTitleDescPeer::$fieldKeys[$fromType][$name]) ? CustomerTitleDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CustomerTitleDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CustomerTitleDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CustomerTitleDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CustomerTitleDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CustomerTitleDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CustomerTitleDescPeer::ID);
+ $criteria->addSelectColumn(CustomerTitleDescPeer::CUSTOMER_TITLE_ID);
+ $criteria->addSelectColumn(CustomerTitleDescPeer::LANG);
+ $criteria->addSelectColumn(CustomerTitleDescPeer::SHORT);
+ $criteria->addSelectColumn(CustomerTitleDescPeer::LONG);
+ $criteria->addSelectColumn(CustomerTitleDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(CustomerTitleDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.SHORT');
+ $criteria->addSelectColumn($alias . '.LONG');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CustomerTitleDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CustomerTitleDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CustomerTitleDescPeer::populateObjects(CustomerTitleDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CustomerTitleDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CustomerTitleDesc $obj A CustomerTitleDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CustomerTitleDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CustomerTitleDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CustomerTitleDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CustomerTitleDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CustomerTitleDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CustomerTitleDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CustomerTitleDescPeer::$instances[$key])) {
+ return CustomerTitleDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CustomerTitleDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to customer_title_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CustomerTitleDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CustomerTitleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CustomerTitleDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CustomerTitleDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CustomerTitleDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CustomerTitleDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CustomerTitleDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CustomerTitleDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CustomerTitleDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CustomerTitleDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CustomerTitleDescPeer::DATABASE_NAME)->getTable(CustomerTitleDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCustomerTitleDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCustomerTitleDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CustomerTitleDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CustomerTitleDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CustomerTitleDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or CustomerTitleDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CustomerTitleDesc object
+ }
+
+ if ($criteria->containsKey(CustomerTitleDescPeer::ID) && $criteria->keyContainsValue(CustomerTitleDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerTitleDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a CustomerTitleDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or CustomerTitleDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CustomerTitleDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CustomerTitleDescPeer::ID);
+ $value = $criteria->remove(CustomerTitleDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CustomerTitleDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CustomerTitleDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is CustomerTitleDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the customer_title_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ CustomerTitleDescPeer::clearInstancePool();
+ CustomerTitleDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CustomerTitleDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CustomerTitleDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(CustomerTitleDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CustomerTitleDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CustomerTitleDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CustomerTitleDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CustomerTitleDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CustomerTitleDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CustomerTitleDescPeer::DATABASE_NAME, CustomerTitleDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CustomerTitleDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CustomerTitleDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CustomerTitleDescPeer::DATABASE_NAME);
+ $criteria->add(CustomerTitleDescPeer::ID, $pk);
+
+ $v = CustomerTitleDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return CustomerTitleDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CustomerTitleDescPeer::DATABASE_NAME);
+ $criteria->add(CustomerTitleDescPeer::ID, $pks, Criteria::IN);
+ $objs = CustomerTitleDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCustomerTitleDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCustomerTitleDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php
new file mode 100644
index 000000000..ff7c9fbec
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php
@@ -0,0 +1,580 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CustomerTitleDesc|CustomerTitleDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CustomerTitleDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CustomerTitleDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CUSTOMER_TITLE_ID`, `LANG`, `SHORT`, `LONG`, `CREATED_AT`, `UPDATED_AT` FROM `customer_title_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new CustomerTitleDesc();
+ $obj->hydrate($row);
+ CustomerTitleDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CustomerTitleDesc|CustomerTitleDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|CustomerTitleDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_title_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
+ * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
+ * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
+ *
+ *
+ * @see filterByCustomerTitle()
+ *
+ * @param mixed $customerTitleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
+ {
+ if (is_array($customerTitleId)) {
+ $useMinMax = false;
+ if (isset($customerTitleId['min'])) {
+ $this->addUsingAlias(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerTitleId['max'])) {
+ $this->addUsingAlias(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the short column
+ *
+ * Example usage:
+ *
+ * $query->filterByShort('fooValue'); // WHERE short = 'fooValue'
+ * $query->filterByShort('%fooValue%'); // WHERE short LIKE '%fooValue%'
+ *
+ *
+ * @param string $short The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterByShort($short = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($short)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $short)) {
+ $short = str_replace('*', '%', $short);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::SHORT, $short, $comparison);
+ }
+
+ /**
+ * Filter the query on the long column
+ *
+ * Example usage:
+ *
+ * $query->filterByLong('fooValue'); // WHERE long = 'fooValue'
+ * $query->filterByLong('%fooValue%'); // WHERE long LIKE '%fooValue%'
+ *
+ *
+ * @param string $long The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterByLong($long = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($long)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $long)) {
+ $long = str_replace('*', '%', $long);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::LONG, $long, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CustomerTitleDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CustomerTitleDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CustomerTitleDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CustomerTitleDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleDescPeer::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 CustomerTitleDescQuery 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(CustomerTitleDescPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
+ } elseif ($customerTitle instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CustomerTitleDescPeer::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 CustomerTitleDescQuery 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
+ *
+ * @param CustomerTitleDesc $customerTitleDesc Object to remove from the list of results
+ *
+ * @return CustomerTitleDescQuery The current query, for fluid interface
+ */
+ public function prune($customerTitleDesc = null)
+ {
+ if ($customerTitleDesc) {
+ $this->addUsingAlias(CustomerTitleDescPeer::ID, $customerTitleDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php
new file mode 100644
index 000000000..ebe4d868d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php
@@ -0,0 +1,791 @@
+ array ('Id', 'DefaultUtility', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'defaultUtility', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (CustomerTitlePeer::ID, CustomerTitlePeer::DEFAULT_UTILITY, CustomerTitlePeer::POSITION, CustomerTitlePeer::CREATED_AT, CustomerTitlePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DEFAULT_UTILITY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'default_utility', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CustomerTitlePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DefaultUtility' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'defaultUtility' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (CustomerTitlePeer::ID => 0, CustomerTitlePeer::DEFAULT_UTILITY => 1, CustomerTitlePeer::POSITION => 2, CustomerTitlePeer::CREATED_AT => 3, CustomerTitlePeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DEFAULT_UTILITY' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'default_utility' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CustomerTitlePeer::getFieldNames($toType);
+ $key = isset(CustomerTitlePeer::$fieldKeys[$fromType][$name]) ? CustomerTitlePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CustomerTitlePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CustomerTitlePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CustomerTitlePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CustomerTitlePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CustomerTitlePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CustomerTitlePeer::ID);
+ $criteria->addSelectColumn(CustomerTitlePeer::DEFAULT_UTILITY);
+ $criteria->addSelectColumn(CustomerTitlePeer::POSITION);
+ $criteria->addSelectColumn(CustomerTitlePeer::CREATED_AT);
+ $criteria->addSelectColumn(CustomerTitlePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.DEFAULT_UTILITY');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CustomerTitle
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CustomerTitlePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CustomerTitlePeer::populateObjects(CustomerTitlePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CustomerTitlePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CustomerTitle $obj A CustomerTitle object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ CustomerTitlePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CustomerTitle object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CustomerTitle) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CustomerTitle object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CustomerTitlePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CustomerTitle Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CustomerTitlePeer::$instances[$key])) {
+ return CustomerTitlePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CustomerTitlePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to customer_title
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CustomerTitlePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CustomerTitlePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CustomerTitlePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CustomerTitle object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CustomerTitlePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CustomerTitlePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CustomerTitlePeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CustomerTitlePeer::DATABASE_NAME)->getTable(CustomerTitlePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCustomerTitlePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCustomerTitlePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CustomerTitleTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CustomerTitlePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CustomerTitle or Criteria object.
+ *
+ * @param mixed $values Criteria or CustomerTitle object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CustomerTitle object
+ }
+
+ if ($criteria->containsKey(CustomerTitlePeer::ID) && $criteria->keyContainsValue(CustomerTitlePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerTitlePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a CustomerTitle or Criteria object.
+ *
+ * @param mixed $values Criteria or CustomerTitle object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CustomerTitlePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CustomerTitlePeer::ID);
+ $value = $criteria->remove(CustomerTitlePeer::ID);
+ if ($value) {
+ $selectCriteria->add(CustomerTitlePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME);
+ }
+
+ } else { // $values is CustomerTitle object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the customer_title table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(CustomerTitlePeer::TABLE_NAME, $con, CustomerTitlePeer::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
+ // instances get re-added by the select statement contained therein).
+ CustomerTitlePeer::clearInstancePool();
+ CustomerTitlePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CustomerTitle or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CustomerTitle object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ CustomerTitlePeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof CustomerTitle) { // it's a model object
+ // invalidate the cache for this single object
+ CustomerTitlePeer::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(CustomerTitlePeer::DATABASE_NAME);
+ $criteria->add(CustomerTitlePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CustomerTitlePeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CustomerTitlePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CustomerTitle object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CustomerTitle $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CustomerTitlePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CustomerTitlePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CustomerTitlePeer::DATABASE_NAME, CustomerTitlePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CustomerTitle
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CustomerTitlePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME);
+ $criteria->add(CustomerTitlePeer::ID, $pk);
+
+ $v = CustomerTitlePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return CustomerTitle[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME);
+ $criteria->add(CustomerTitlePeer::ID, $pks, Criteria::IN);
+ $objs = CustomerTitlePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCustomerTitlePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCustomerTitlePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php
new file mode 100644
index 000000000..0e0ac3100
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php
@@ -0,0 +1,668 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CustomerTitle|CustomerTitle[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CustomerTitlePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CustomerTitle A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `DEFAULT_UTILITY`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `customer_title` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new CustomerTitle();
+ $obj->hydrate($row);
+ CustomerTitlePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CustomerTitle|CustomerTitle[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|CustomerTitle[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CustomerTitlePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CustomerTitlePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CustomerTitlePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the default_utility column
+ *
+ * Example usage:
+ *
+ * $query->filterByDefaultUtility(1234); // WHERE default_utility = 1234
+ * $query->filterByDefaultUtility(array(12, 34)); // WHERE default_utility IN (12, 34)
+ * $query->filterByDefaultUtility(array('min' => 12)); // WHERE default_utility > 12
+ *
+ *
+ * @param mixed $defaultUtility The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByDefaultUtility($defaultUtility = null, $comparison = null)
+ {
+ if (is_array($defaultUtility)) {
+ $useMinMax = false;
+ if (isset($defaultUtility['min'])) {
+ $this->addUsingAlias(CustomerTitlePeer::DEFAULT_UTILITY, $defaultUtility['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($defaultUtility['max'])) {
+ $this->addUsingAlias(CustomerTitlePeer::DEFAULT_UTILITY, $defaultUtility['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitlePeer::DEFAULT_UTILITY, $defaultUtility, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition('fooValue'); // WHERE position = 'fooValue'
+ * $query->filterByPosition('%fooValue%'); // WHERE position LIKE '%fooValue%'
+ *
+ *
+ * @param string $position The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($position)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $position)) {
+ $position = str_replace('*', '%', $position);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitlePeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Address object
+ *
+ * @param Address|PropelObjectCollection $address the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAddress($address, $comparison = null)
+ {
+ if ($address instanceof Address) {
+ return $this
+ ->addUsingAlias(CustomerTitlePeer::ID, $address->getCustomerTitleId(), $comparison);
+ } elseif ($address instanceof PropelObjectCollection) {
+ return $this
+ ->useAddressQuery()
+ ->filterByPrimaryKeys($address->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Address relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Address');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Address');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Address relation Address object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query
+ */
+ public function useAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinAddress($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
+ }
+
+ /**
+ * Filter the query by a related Customer object
+ *
+ * @param Customer|PropelObjectCollection $customer the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCustomer($customer, $comparison = null)
+ {
+ if ($customer instanceof Customer) {
+ return $this
+ ->addUsingAlias(CustomerTitlePeer::ID, $customer->getCustomerTitleId(), $comparison);
+ } elseif ($customer instanceof PropelObjectCollection) {
+ return $this
+ ->useCustomerQuery()
+ ->filterByPrimaryKeys($customer->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Customer relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Customer');
+
+ // 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, 'Customer');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Customer relation Customer 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\CustomerQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCustomer($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
+ }
+
+ /**
+ * Filter the query by a related CustomerTitleDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCustomerTitleDesc($customerTitleDesc, $comparison = null)
+ {
+ if ($customerTitleDesc instanceof CustomerTitleDesc) {
+ return $this
+ ->addUsingAlias(CustomerTitlePeer::ID, $customerTitleDesc->getCustomerTitleId(), $comparison);
+ } elseif ($customerTitleDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useCustomerTitleDescQuery()
+ ->filterByPrimaryKeys($customerTitleDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCustomerTitleDesc() only accepts arguments of type CustomerTitleDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CustomerTitleDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function joinCustomerTitleDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CustomerTitleDesc');
+
+ // 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, 'CustomerTitleDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CustomerTitleDesc relation CustomerTitleDesc 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\CustomerTitleDescQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerTitleDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCustomerTitleDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CustomerTitleDesc', '\Thelia\Model\CustomerTitleDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param CustomerTitle $customerTitle Object to remove from the list of results
+ *
+ * @return CustomerTitleQuery The current query, for fluid interface
+ */
+ public function prune($customerTitle = null)
+ {
+ if ($customerTitle) {
+ $this->addUsingAlias(CustomerTitlePeer::ID, $customerTitle->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseDelivzone.php b/core/lib/Thelia/Model/om/BaseDelivzone.php
new file mode 100644
index 000000000..a1e31aa18
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDelivzone.php
@@ -0,0 +1,1155 @@
+id;
+ }
+
+ /**
+ * Get the [area_id] column value.
+ *
+ * @return int
+ */
+ public function getAreaId()
+ {
+ return $this->area_id;
+ }
+
+ /**
+ * Get the [delivery] column value.
+ *
+ * @return string
+ */
+ public function getDelivery()
+ {
+ return $this->delivery;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Delivzone The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = DelivzonePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [area_id] column.
+ *
+ * @param int $v new value
+ * @return Delivzone The current object (for fluent API support)
+ */
+ public function setAreaId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->area_id !== $v) {
+ $this->area_id = $v;
+ $this->modifiedColumns[] = DelivzonePeer::AREA_ID;
+ }
+
+ if ($this->aArea !== null && $this->aArea->getId() !== $v) {
+ $this->aArea = null;
+ }
+
+
+ return $this;
+ } // setAreaId()
+
+ /**
+ * Set the value of [delivery] column.
+ *
+ * @param string $v new value
+ * @return Delivzone The current object (for fluent API support)
+ */
+ public function setDelivery($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->delivery !== $v) {
+ $this->delivery = $v;
+ $this->modifiedColumns[] = DelivzonePeer::DELIVERY;
+ }
+
+
+ return $this;
+ } // setDelivery()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Delivzone The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = DelivzonePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Delivzone The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = DelivzonePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->area_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->delivery = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = DelivzonePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Delivzone object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) {
+ $this->aArea = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = DelivzonePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aArea = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = DelivzoneQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ DelivzonePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = DelivzonePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . DelivzonePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(DelivzonePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(DelivzonePeer::AREA_ID)) {
+ $modifiedColumns[':p' . $index++] = '`AREA_ID`';
+ }
+ if ($this->isColumnModified(DelivzonePeer::DELIVERY)) {
+ $modifiedColumns[':p' . $index++] = '`DELIVERY`';
+ }
+ if ($this->isColumnModified(DelivzonePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(DelivzonePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `delivzone` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`AREA_ID`':
+ $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT);
+ break;
+ case '`DELIVERY`':
+ $stmt->bindValue($identifier, $this->delivery, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = DelivzonePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getAreaId();
+ break;
+ case 2:
+ return $this->getDelivery();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()] = true;
+ $keys = DelivzonePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAreaId(),
+ $keys[2] => $this->getDelivery(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aArea) {
+ $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = DelivzonePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setAreaId($value);
+ break;
+ case 2:
+ $this->setDelivery($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = DelivzonePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setDelivery($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(DelivzonePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(DelivzonePeer::ID)) $criteria->add(DelivzonePeer::ID, $this->id);
+ if ($this->isColumnModified(DelivzonePeer::AREA_ID)) $criteria->add(DelivzonePeer::AREA_ID, $this->area_id);
+ if ($this->isColumnModified(DelivzonePeer::DELIVERY)) $criteria->add(DelivzonePeer::DELIVERY, $this->delivery);
+ if ($this->isColumnModified(DelivzonePeer::CREATED_AT)) $criteria->add(DelivzonePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(DelivzonePeer::UPDATED_AT)) $criteria->add(DelivzonePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(DelivzonePeer::DATABASE_NAME);
+ $criteria->add(DelivzonePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Delivzone (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAreaId($this->getAreaId());
+ $copyObj->setDelivery($this->getDelivery());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Delivzone Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return DelivzonePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new DelivzonePeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Area object.
+ *
+ * @param Area $v
+ * @return Delivzone The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setArea(Area $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->area_id = null;
+ $this->delivery = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aArea = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(DelivzonePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseDelivzonePeer.php b/core/lib/Thelia/Model/om/BaseDelivzonePeer.php
new file mode 100644
index 000000000..c2cbaf9a0
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDelivzonePeer.php
@@ -0,0 +1,1022 @@
+ array ('Id', 'AreaId', 'Delivery', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'areaId', 'delivery', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (DelivzonePeer::ID, DelivzonePeer::AREA_ID, DelivzonePeer::DELIVERY, DelivzonePeer::CREATED_AT, DelivzonePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'AREA_ID', 'DELIVERY', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'area_id', 'delivery', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. DelivzonePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AreaId' => 1, 'Delivery' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'areaId' => 1, 'delivery' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (DelivzonePeer::ID => 0, DelivzonePeer::AREA_ID => 1, DelivzonePeer::DELIVERY => 2, DelivzonePeer::CREATED_AT => 3, DelivzonePeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'AREA_ID' => 1, 'DELIVERY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'area_id' => 1, 'delivery' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = DelivzonePeer::getFieldNames($toType);
+ $key = isset(DelivzonePeer::$fieldKeys[$fromType][$name]) ? DelivzonePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(DelivzonePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, DelivzonePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return DelivzonePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. DelivzonePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(DelivzonePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(DelivzonePeer::ID);
+ $criteria->addSelectColumn(DelivzonePeer::AREA_ID);
+ $criteria->addSelectColumn(DelivzonePeer::DELIVERY);
+ $criteria->addSelectColumn(DelivzonePeer::CREATED_AT);
+ $criteria->addSelectColumn(DelivzonePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.AREA_ID');
+ $criteria->addSelectColumn($alias . '.DELIVERY');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Delivzone
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = DelivzonePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return DelivzonePeer::populateObjects(DelivzonePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ DelivzonePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Delivzone $obj A Delivzone object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ DelivzonePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Delivzone object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Delivzone) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Delivzone object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(DelivzonePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Delivzone Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(DelivzonePeer::$instances[$key])) {
+ return DelivzonePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ DelivzonePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to delivzone
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = DelivzonePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = DelivzonePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = DelivzonePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ DelivzonePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Delivzone object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = DelivzonePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = DelivzonePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + DelivzonePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = DelivzonePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ DelivzonePeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(DelivzonePeer::DATABASE_NAME)->getTable(DelivzonePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseDelivzonePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseDelivzonePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new DelivzoneTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return DelivzonePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Delivzone or Criteria object.
+ *
+ * @param mixed $values Criteria or Delivzone object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Delivzone object
+ }
+
+ if ($criteria->containsKey(DelivzonePeer::ID) && $criteria->keyContainsValue(DelivzonePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.DelivzonePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Delivzone or Criteria object.
+ *
+ * @param mixed $values Criteria or Delivzone object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(DelivzonePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(DelivzonePeer::ID);
+ $value = $criteria->remove(DelivzonePeer::ID);
+ if ($value) {
+ $selectCriteria->add(DelivzonePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(DelivzonePeer::TABLE_NAME);
+ }
+
+ } else { // $values is Delivzone object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the delivzone table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ DelivzonePeer::clearInstancePool();
+ DelivzonePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Delivzone or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Delivzone object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(DelivzonePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ DelivzonePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Delivzone object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Delivzone $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(DelivzonePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(DelivzonePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(DelivzonePeer::DATABASE_NAME, DelivzonePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Delivzone
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = DelivzonePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(DelivzonePeer::DATABASE_NAME);
+ $criteria->add(DelivzonePeer::ID, $pk);
+
+ $v = DelivzonePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Delivzone[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(DelivzonePeer::DATABASE_NAME);
+ $criteria->add(DelivzonePeer::ID, $pks, Criteria::IN);
+ $objs = DelivzonePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseDelivzonePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseDelivzonePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php
new file mode 100644
index 000000000..abfaf373d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php
@@ -0,0 +1,514 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Delivzone|Delivzone[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = DelivzonePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Delivzone A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `AREA_ID`, `DELIVERY`, `CREATED_AT`, `UPDATED_AT` FROM `delivzone` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Delivzone();
+ $obj->hydrate($row);
+ DelivzonePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Delivzone|Delivzone[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Delivzone[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return DelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(DelivzonePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return DelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(DelivzonePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DelivzoneQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(DelivzonePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the area_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAreaId(1234); // WHERE area_id = 1234
+ * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34)
+ * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12
+ *
+ *
+ * @see filterByArea()
+ *
+ * @param mixed $areaId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByAreaId($areaId = null, $comparison = null)
+ {
+ if (is_array($areaId)) {
+ $useMinMax = false;
+ if (isset($areaId['min'])) {
+ $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($areaId['max'])) {
+ $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId, $comparison);
+ }
+
+ /**
+ * Filter the query on the delivery column
+ *
+ * Example usage:
+ *
+ * $query->filterByDelivery('fooValue'); // WHERE delivery = 'fooValue'
+ * $query->filterByDelivery('%fooValue%'); // WHERE delivery LIKE '%fooValue%'
+ *
+ *
+ * @param string $delivery The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByDelivery($delivery = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($delivery)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $delivery)) {
+ $delivery = str_replace('*', '%', $delivery);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzonePeer::DELIVERY, $delivery, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzonePeer::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 DelivzoneQuery 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(DelivzonePeer::AREA_ID, $area->getId(), $comparison);
+ } elseif ($area instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DelivzonePeer::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 DelivzoneQuery 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');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Delivzone $delivzone Object to remove from the list of results
+ *
+ * @return DelivzoneQuery The current query, for fluid interface
+ */
+ public function prune($delivzone = null)
+ {
+ if ($delivzone) {
+ $this->addUsingAlias(DelivzonePeer::ID, $delivzone->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseDocument.php b/core/lib/Thelia/Model/om/BaseDocument.php
new file mode 100644
index 000000000..cad17c959
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDocument.php
@@ -0,0 +1,1908 @@
+id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+ return $this->folder_id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [file] column value.
+ *
+ * @return string
+ */
+ public function getFile()
+ {
+ return $this->file;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Document The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = DocumentPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return Document The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = DocumentPeer::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return Document The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = DocumentPeer::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return Document The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = DocumentPeer::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return Document The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = DocumentPeer::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [file] column.
+ *
+ * @param string $v new value
+ * @return Document The current object (for fluent API support)
+ */
+ public function setFile($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->file !== $v) {
+ $this->file = $v;
+ $this->modifiedColumns[] = DocumentPeer::FILE;
+ }
+
+
+ return $this;
+ } // setFile()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Document The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = DocumentPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Document The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = DocumentPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Document The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = DocumentPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->category_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->folder_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->content_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->file = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
+ $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = DocumentPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Document object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = DocumentPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ $this->collDocumentDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = DocumentQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ DocumentPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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->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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->documentDescsScheduledForDeletion !== null) {
+ if (!$this->documentDescsScheduledForDeletion->isEmpty()) {
+ DocumentDescQuery::create()
+ ->filterByPrimaryKeys($this->documentDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->documentDescsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collDocumentDescs !== null) {
+ foreach ($this->collDocumentDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = DocumentPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . DocumentPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(DocumentPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(DocumentPeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(DocumentPeer::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`';
+ }
+ if ($this->isColumnModified(DocumentPeer::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FOLDER_ID`';
+ }
+ if ($this->isColumnModified(DocumentPeer::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CONTENT_ID`';
+ }
+ if ($this->isColumnModified(DocumentPeer::FILE)) {
+ $modifiedColumns[':p' . $index++] = '`FILE`';
+ }
+ if ($this->isColumnModified(DocumentPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(DocumentPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(DocumentPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `document` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`CATEGORY_ID`':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case '`FOLDER_ID`':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ case '`CONTENT_ID`':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case '`FILE`':
+ $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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->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 = DocumentPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ if ($this->collDocumentDescs !== null) {
+ foreach ($this->collDocumentDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = DocumentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getProductId();
+ break;
+ case 2:
+ return $this->getCategoryId();
+ break;
+ case 3:
+ return $this->getFolderId();
+ break;
+ case 4:
+ return $this->getContentId();
+ break;
+ case 5:
+ return $this->getFile();
+ break;
+ case 6:
+ return $this->getPosition();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Document'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Document'][$this->getPrimaryKey()] = true;
+ $keys = DocumentPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getCategoryId(),
+ $keys[3] => $this->getFolderId(),
+ $keys[4] => $this->getContentId(),
+ $keys[5] => $this->getFile(),
+ $keys[6] => $this->getPosition(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collDocumentDescs) {
+ $result['DocumentDescs'] = $this->collDocumentDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = DocumentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setProductId($value);
+ break;
+ case 2:
+ $this->setCategoryId($value);
+ break;
+ case 3:
+ $this->setFolderId($value);
+ break;
+ case 4:
+ $this->setContentId($value);
+ break;
+ case 5:
+ $this->setFile($value);
+ break;
+ case 6:
+ $this->setPosition($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = DocumentPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(DocumentPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(DocumentPeer::ID)) $criteria->add(DocumentPeer::ID, $this->id);
+ if ($this->isColumnModified(DocumentPeer::PRODUCT_ID)) $criteria->add(DocumentPeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(DocumentPeer::CATEGORY_ID)) $criteria->add(DocumentPeer::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(DocumentPeer::FOLDER_ID)) $criteria->add(DocumentPeer::FOLDER_ID, $this->folder_id);
+ if ($this->isColumnModified(DocumentPeer::CONTENT_ID)) $criteria->add(DocumentPeer::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(DocumentPeer::FILE)) $criteria->add(DocumentPeer::FILE, $this->file);
+ if ($this->isColumnModified(DocumentPeer::POSITION)) $criteria->add(DocumentPeer::POSITION, $this->position);
+ if ($this->isColumnModified(DocumentPeer::CREATED_AT)) $criteria->add(DocumentPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(DocumentPeer::UPDATED_AT)) $criteria->add(DocumentPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(DocumentPeer::DATABASE_NAME);
+ $criteria->add(DocumentPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Document (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setFolderId($this->getFolderId());
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setFile($this->getFile());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Document Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return DocumentPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new DocumentPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return Document The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(Product $v = null)
+ {
+ 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->addDocument($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->addDocuments($this);
+ */
+ }
+
+ 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;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('DocumentDesc' == $relationName) {
+ $this->initDocumentDescs();
+ }
+ }
+
+ /**
+ * 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 PropelObjectCollection|DocumentDesc[] List of DocumentDesc objects
+ * @throws PropelException
+ */
+ 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);
+
+ 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->collDocumentDescs;
+ }
+
+ /**
+ * 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 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 countDocumentDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $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();
+ }
+
+ 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;
+ }
+
+ /**
+ * @param DocumentDesc $documentDesc The documentDesc object to add.
+ */
+ protected function doAddDocumentDesc($documentDesc)
+ {
+ $this->collDocumentDescs[]= $documentDesc;
+ $documentDesc->setDocument($this);
+ }
+
+ /**
+ * @param DocumentDesc $documentDesc The documentDesc object to remove.
+ */
+ public function removeDocumentDesc($documentDesc)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->category_id = null;
+ $this->folder_id = null;
+ $this->content_id = null;
+ $this->file = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collDocumentDescs) {
+ foreach ($this->collDocumentDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collDocumentDescs instanceof PropelCollection) {
+ $this->collDocumentDescs->clearIterator();
+ }
+ $this->collDocumentDescs = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(DocumentPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseDocumentDesc.php b/core/lib/Thelia/Model/om/BaseDocumentDesc.php
new file mode 100644
index 000000000..3c341edc7
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDocumentDesc.php
@@ -0,0 +1,1320 @@
+id;
+ }
+
+ /**
+ * Get the [document_id] column value.
+ *
+ * @return int
+ */
+ public function getDocumentId()
+ {
+ return $this->document_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return DocumentDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = DocumentDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [document_id] column.
+ *
+ * @param int $v new value
+ * @return DocumentDesc The current object (for fluent API support)
+ */
+ public function setDocumentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->document_id !== $v) {
+ $this->document_id = $v;
+ $this->modifiedColumns[] = DocumentDescPeer::DOCUMENT_ID;
+ }
+
+ if ($this->aDocument !== null && $this->aDocument->getId() !== $v) {
+ $this->aDocument = null;
+ }
+
+
+ return $this;
+ } // setDocumentId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return DocumentDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = DocumentDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return DocumentDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = DocumentDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return DocumentDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = DocumentDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return DocumentDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = DocumentDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return DocumentDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = DocumentDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return DocumentDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = DocumentDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->document_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = DocumentDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating DocumentDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aDocument !== null && $this->document_id !== $this->aDocument->getId()) {
+ $this->aDocument = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = DocumentDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aDocument = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = DocumentDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ DocumentDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = DocumentDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . DocumentDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(DocumentDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(DocumentDescPeer::DOCUMENT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`DOCUMENT_ID`';
+ }
+ if ($this->isColumnModified(DocumentDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(DocumentDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(DocumentDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(DocumentDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(DocumentDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(DocumentDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `document_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`DOCUMENT_ID`':
+ $stmt->bindValue($identifier, $this->document_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = DocumentDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getDocumentId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['DocumentDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['DocumentDesc'][$this->getPrimaryKey()] = true;
+ $keys = DocumentDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getDocumentId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aDocument) {
+ $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = DocumentDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setDocumentId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = DocumentDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setDocumentId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(DocumentDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(DocumentDescPeer::ID)) $criteria->add(DocumentDescPeer::ID, $this->id);
+ if ($this->isColumnModified(DocumentDescPeer::DOCUMENT_ID)) $criteria->add(DocumentDescPeer::DOCUMENT_ID, $this->document_id);
+ if ($this->isColumnModified(DocumentDescPeer::LANG)) $criteria->add(DocumentDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(DocumentDescPeer::TITLE)) $criteria->add(DocumentDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(DocumentDescPeer::DESCRIPTION)) $criteria->add(DocumentDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(DocumentDescPeer::CHAPO)) $criteria->add(DocumentDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(DocumentDescPeer::CREATED_AT)) $criteria->add(DocumentDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(DocumentDescPeer::UPDATED_AT)) $criteria->add(DocumentDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(DocumentDescPeer::DATABASE_NAME);
+ $criteria->add(DocumentDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of DocumentDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setDocumentId($this->getDocumentId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return DocumentDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return DocumentDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new DocumentDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Document object.
+ *
+ * @param Document $v
+ * @return DocumentDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setDocument(Document $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->document_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aDocument = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(DocumentDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseDocumentDescPeer.php b/core/lib/Thelia/Model/om/BaseDocumentDescPeer.php
new file mode 100644
index 000000000..013588697
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDocumentDescPeer.php
@@ -0,0 +1,1037 @@
+ array ('Id', 'DocumentId', 'Lang', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'documentId', 'lang', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (DocumentDescPeer::ID, DocumentDescPeer::DOCUMENT_ID, DocumentDescPeer::LANG, DocumentDescPeer::TITLE, DocumentDescPeer::DESCRIPTION, DocumentDescPeer::CHAPO, DocumentDescPeer::CREATED_AT, DocumentDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DOCUMENT_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'document_id', 'lang', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. DocumentDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DocumentId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'documentId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (DocumentDescPeer::ID => 0, DocumentDescPeer::DOCUMENT_ID => 1, DocumentDescPeer::LANG => 2, DocumentDescPeer::TITLE => 3, DocumentDescPeer::DESCRIPTION => 4, DocumentDescPeer::CHAPO => 5, DocumentDescPeer::CREATED_AT => 6, DocumentDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DOCUMENT_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'document_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = DocumentDescPeer::getFieldNames($toType);
+ $key = isset(DocumentDescPeer::$fieldKeys[$fromType][$name]) ? DocumentDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(DocumentDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, DocumentDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return DocumentDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. DocumentDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(DocumentDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(DocumentDescPeer::ID);
+ $criteria->addSelectColumn(DocumentDescPeer::DOCUMENT_ID);
+ $criteria->addSelectColumn(DocumentDescPeer::LANG);
+ $criteria->addSelectColumn(DocumentDescPeer::TITLE);
+ $criteria->addSelectColumn(DocumentDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(DocumentDescPeer::CHAPO);
+ $criteria->addSelectColumn(DocumentDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(DocumentDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.DOCUMENT_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return DocumentDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = DocumentDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return DocumentDescPeer::populateObjects(DocumentDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ DocumentDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param DocumentDesc $obj A DocumentDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ DocumentDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A DocumentDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof DocumentDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or DocumentDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(DocumentDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return DocumentDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(DocumentDescPeer::$instances[$key])) {
+ return DocumentDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ DocumentDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to document_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = DocumentDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = DocumentDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = DocumentDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ DocumentDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (DocumentDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = DocumentDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = DocumentDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + DocumentDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = DocumentDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ DocumentDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(DocumentDescPeer::DATABASE_NAME)->getTable(DocumentDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseDocumentDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseDocumentDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new DocumentDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return DocumentDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a DocumentDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or DocumentDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from DocumentDesc object
+ }
+
+ if ($criteria->containsKey(DocumentDescPeer::ID) && $criteria->keyContainsValue(DocumentDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.DocumentDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a DocumentDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or DocumentDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(DocumentDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(DocumentDescPeer::ID);
+ $value = $criteria->remove(DocumentDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(DocumentDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(DocumentDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is DocumentDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the document_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ DocumentDescPeer::clearInstancePool();
+ DocumentDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a DocumentDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or DocumentDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(DocumentDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ DocumentDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given DocumentDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param DocumentDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(DocumentDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(DocumentDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(DocumentDescPeer::DATABASE_NAME, DocumentDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return DocumentDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = DocumentDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(DocumentDescPeer::DATABASE_NAME);
+ $criteria->add(DocumentDescPeer::ID, $pk);
+
+ $v = DocumentDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return DocumentDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(DocumentDescPeer::DATABASE_NAME);
+ $criteria->add(DocumentDescPeer::ID, $pks, Criteria::IN);
+ $objs = DocumentDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseDocumentDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseDocumentDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php b/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php
new file mode 100644
index 000000000..5d1597689
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php
@@ -0,0 +1,613 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return DocumentDesc|DocumentDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = DocumentDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return DocumentDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `DOCUMENT_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `document_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new DocumentDesc();
+ $obj->hydrate($row);
+ DocumentDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return DocumentDesc|DocumentDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|DocumentDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(DocumentDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(DocumentDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(DocumentDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the document_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByDocumentId(1234); // WHERE document_id = 1234
+ * $query->filterByDocumentId(array(12, 34)); // WHERE document_id IN (12, 34)
+ * $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.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByDocumentId($documentId = null, $comparison = null)
+ {
+ if (is_array($documentId)) {
+ $useMinMax = false;
+ if (isset($documentId['min'])) {
+ $this->addUsingAlias(DocumentDescPeer::DOCUMENT_ID, $documentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($documentId['max'])) {
+ $this->addUsingAlias(DocumentDescPeer::DOCUMENT_ID, $documentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentDescPeer::DOCUMENT_ID, $documentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(DocumentDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(DocumentDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(DocumentDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(DocumentDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Document object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof Document) {
+ return $this
+ ->addUsingAlias(DocumentDescPeer::DOCUMENT_ID, $document->getId(), $comparison);
+ } elseif ($document instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentDescPeer::DOCUMENT_ID, $document->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param DocumentDesc $documentDesc Object to remove from the list of results
+ *
+ * @return DocumentDescQuery The current query, for fluid interface
+ */
+ public function prune($documentDesc = null)
+ {
+ if ($documentDesc) {
+ $this->addUsingAlias(DocumentDescPeer::ID, $documentDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseDocumentPeer.php b/core/lib/Thelia/Model/om/BaseDocumentPeer.php
new file mode 100644
index 000000000..0f8da5499
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDocumentPeer.php
@@ -0,0 +1,2186 @@
+ array ('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (DocumentPeer::ID, DocumentPeer::PRODUCT_ID, DocumentPeer::CATEGORY_ID, DocumentPeer::FOLDER_ID, DocumentPeer::CONTENT_ID, DocumentPeer::FILE, DocumentPeer::POSITION, DocumentPeer::CREATED_AT, DocumentPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. DocumentPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ BasePeer::TYPE_COLNAME => array (DocumentPeer::ID => 0, DocumentPeer::PRODUCT_ID => 1, DocumentPeer::CATEGORY_ID => 2, DocumentPeer::FOLDER_ID => 3, DocumentPeer::CONTENT_ID => 4, DocumentPeer::FILE => 5, DocumentPeer::POSITION => 6, DocumentPeer::CREATED_AT => 7, DocumentPeer::UPDATED_AT => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'CATEGORY_ID' => 2, 'FOLDER_ID' => 3, 'CONTENT_ID' => 4, 'FILE' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'category_id' => 2, 'folder_id' => 3, 'content_id' => 4, 'file' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = DocumentPeer::getFieldNames($toType);
+ $key = isset(DocumentPeer::$fieldKeys[$fromType][$name]) ? DocumentPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(DocumentPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, DocumentPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return DocumentPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. DocumentPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(DocumentPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(DocumentPeer::ID);
+ $criteria->addSelectColumn(DocumentPeer::PRODUCT_ID);
+ $criteria->addSelectColumn(DocumentPeer::CATEGORY_ID);
+ $criteria->addSelectColumn(DocumentPeer::FOLDER_ID);
+ $criteria->addSelectColumn(DocumentPeer::CONTENT_ID);
+ $criteria->addSelectColumn(DocumentPeer::FILE);
+ $criteria->addSelectColumn(DocumentPeer::POSITION);
+ $criteria->addSelectColumn(DocumentPeer::CREATED_AT);
+ $criteria->addSelectColumn(DocumentPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.FILE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Document
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = DocumentPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return DocumentPeer::populateObjects(DocumentPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ DocumentPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Document $obj A Document object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ DocumentPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Document object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Document) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Document object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(DocumentPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Document Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(DocumentPeer::$instances[$key])) {
+ return DocumentPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ DocumentPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to document
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in DocumentDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ DocumentDescPeer::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = DocumentPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = DocumentPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ DocumentPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Document object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = DocumentPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + DocumentPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = DocumentPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ DocumentPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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(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::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(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
+ * @return array Array of Document 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(DocumentPeer::DATABASE_NAME);
+ }
+
+ DocumentPeer::addSelectColumns($criteria);
+ $startcol = DocumentPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::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 = 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 (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
+
+ $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(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::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);
+
+ if ($row = $stmt->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.
+ *
+ * @param 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 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(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;
+
+ 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();
+
+ 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 loaded
+
+ // 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();
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(DocumentPeer::DATABASE_NAME)->getTable(DocumentPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseDocumentPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseDocumentPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new DocumentTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return DocumentPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Document or Criteria object.
+ *
+ * @param mixed $values Criteria or Document object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Document object
+ }
+
+ if ($criteria->containsKey(DocumentPeer::ID) && $criteria->keyContainsValue(DocumentPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.DocumentPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Document or Criteria object.
+ *
+ * @param mixed $values Criteria or Document object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(DocumentPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(DocumentPeer::ID);
+ $value = $criteria->remove(DocumentPeer::ID);
+ if ($value) {
+ $selectCriteria->add(DocumentPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(DocumentPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Document object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the document table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ DocumentPeer::clearInstancePool();
+ DocumentPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Document or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Document object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(DocumentPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ DocumentPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Document object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Document $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(DocumentPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(DocumentPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(DocumentPeer::DATABASE_NAME, DocumentPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Document
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = DocumentPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(DocumentPeer::DATABASE_NAME);
+ $criteria->add(DocumentPeer::ID, $pk);
+
+ $v = DocumentPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Document[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(DocumentPeer::DATABASE_NAME);
+ $criteria->add(DocumentPeer::ID, $pks, Criteria::IN);
+ $objs = DocumentPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseDocumentPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseDocumentPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseDocumentQuery.php b/core/lib/Thelia/Model/om/BaseDocumentQuery.php
new file mode 100644
index 000000000..ce4457035
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseDocumentQuery.php
@@ -0,0 +1,1022 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Document|Document[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = DocumentPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Document A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PRODUCT_ID`, `CATEGORY_ID`, `FOLDER_ID`, `CONTENT_ID`, `FILE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `document` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Document();
+ $obj->hydrate($row);
+ DocumentPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Document|Document[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Document[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(DocumentPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(DocumentPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(DocumentPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(DocumentPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(DocumentPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentPeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(DocumentPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(DocumentPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentPeer::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId)) {
+ $useMinMax = false;
+ if (isset($folderId['min'])) {
+ $this->addUsingAlias(DocumentPeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($folderId['max'])) {
+ $this->addUsingAlias(DocumentPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentPeer::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(DocumentPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(DocumentPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentPeer::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the file column
+ *
+ * Example usage:
+ *
+ * $query->filterByFile('fooValue'); // WHERE file = 'fooValue'
+ * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%'
+ *
+ *
+ * @param string $file The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByFile($file = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($file)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $file)) {
+ $file = str_replace('*', '%', $file);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentPeer::FILE, $file, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(DocumentPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(DocumentPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(DocumentPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(DocumentPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(DocumentPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(DocumentPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ 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 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 filterByDocumentDesc($documentDesc, $comparison = null)
+ {
+ if ($documentDesc instanceof DocumentDesc) {
+ return $this
+ ->addUsingAlias(DocumentPeer::ID, $documentDesc->getDocumentId(), $comparison);
+ } elseif ($documentDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useDocumentDescQuery()
+ ->filterByPrimaryKeys($documentDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocumentDesc() only accepts arguments of type DocumentDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the DocumentDesc 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 joinDocumentDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('DocumentDesc');
+
+ // 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, 'DocumentDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the DocumentDesc relation DocumentDesc 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\DocumentDescQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinDocumentDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'DocumentDesc', '\Thelia\Model\DocumentDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Document $document Object to remove from the list of results
+ *
+ * @return DocumentQuery The current query, for fluid interface
+ */
+ public function prune($document = null)
+ {
+ if ($document) {
+ $this->addUsingAlias(DocumentPeer::ID, $document->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeature.php b/core/lib/Thelia/Model/om/BaseFeature.php
new file mode 100644
index 000000000..773ad7232
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeature.php
@@ -0,0 +1,2254 @@
+visible = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseFeature object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Feature The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeaturePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return Feature The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = FeaturePeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Feature The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = FeaturePeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Feature The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = FeaturePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Feature The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = FeaturePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->visible !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->visible = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = FeaturePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Feature object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = FeaturePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collFeatureAvs = null;
+
+ $this->collFeatureCategorys = null;
+
+ $this->collFeatureDescs = null;
+
+ $this->collFeatureProds = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FeatureQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeaturePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeaturePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeaturePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeaturePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FeaturePeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(FeaturePeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(FeaturePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `feature` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`VISIBLE`':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getVisible();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Feature'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Feature'][$this->getPrimaryKey()] = true;
+ $keys = FeaturePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getVisible(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collFeatureAvs) {
+ $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureCategorys) {
+ $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureDescs) {
+ $result['FeatureDescs'] = $this->collFeatureDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setVisible($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = FeaturePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeaturePeer::ID)) $criteria->add(FeaturePeer::ID, $this->id);
+ if ($this->isColumnModified(FeaturePeer::VISIBLE)) $criteria->add(FeaturePeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(FeaturePeer::POSITION)) $criteria->add(FeaturePeer::POSITION, $this->position);
+ if ($this->isColumnModified(FeaturePeer::CREATED_AT)) $criteria->add(FeaturePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) $criteria->add(FeaturePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
+ $criteria->add(FeaturePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Feature (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getFeatureAvs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureAv($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureCategorys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Feature Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return FeaturePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FeaturePeer();
+ }
+
+ 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.
+ *
+ * @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 getFeatureAvs($criteria = null, PropelPDO $con = 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 {
+ return count($this->collFeatureAvs);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param FeatureAv $featureAv The featureAv object to add.
+ */
+ protected function doAddFeatureAv($featureAv)
+ {
+ $this->collFeatureAvs[]= $featureAv;
+ $featureAv->setFeature($this);
+ }
+
+ /**
+ * @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
+ *
+ * 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 getFeatureCategorys($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collFeatureCategorysPartial && !$this->isNew();
+ if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureCategorys) {
+ // return empty collection
+ $this->initFeatureCategorys();
+ } else {
+ $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria)
+ ->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 {
+ return count($this->collFeatureCategorys);
+ }
+ }
+
+ /**
+ * Method called to associate a FeatureCategory object to this object
+ * through the FeatureCategory foreign key attribute.
+ *
+ * @param FeatureCategory $l FeatureCategory
+ * @return 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;
+ }
+
+ /**
+ * @param FeatureCategory $featureCategory The featureCategory object to add.
+ */
+ protected function doAddFeatureCategory($featureCategory)
+ {
+ $this->collFeatureCategorys[]= $featureCategory;
+ $featureCategory->setFeature($this);
+ }
+
+ /**
+ * @param FeatureCategory $featureCategory The featureCategory object to remove.
+ */
+ public function removeFeatureCategory($featureCategory)
+ {
+ if ($this->getFeatureCategorys()->contains($featureCategory)) {
+ $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory));
+ if (null === $this->featureCategorysScheduledForDeletion) {
+ $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys;
+ $this->featureCategorysScheduledForDeletion->clear();
+ }
+ $this->featureCategorysScheduledForDeletion[]= $featureCategory;
+ $featureCategory->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.
+ *
+ * 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 getFeatureDescs($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collFeatureDescsPartial && !$this->isNew();
+ if (null === $this->collFeatureDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureDescs) {
+ // return empty collection
+ $this->initFeatureDescs();
+ } else {
+ $collFeatureDescs = FeatureDescQuery::create(null, $criteria)
+ ->filterByFeature($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureDescsPartial && count($collFeatureDescs)) {
+ $this->initFeatureDescs(false);
+
+ foreach($collFeatureDescs as $obj) {
+ if (false == $this->collFeatureDescs->contains($obj)) {
+ $this->collFeatureDescs->append($obj);
+ }
+ }
+
+ $this->collFeatureDescsPartial = true;
+ }
+
+ return $collFeatureDescs;
+ }
+
+ if($partial && $this->collFeatureDescs) {
+ foreach($this->collFeatureDescs as $obj) {
+ if($obj->isNew()) {
+ $collFeatureDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureDescs = $collFeatureDescs;
+ $this->collFeatureDescsPartial = false;
+ }
+ }
+
+ return $this->collFeatureDescs;
+ }
+
+ /**
+ * Sets a collection of FeatureDesc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $featureDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setFeatureDescs(PropelCollection $featureDescs, PropelPDO $con = null)
+ {
+ $this->featureDescsScheduledForDeletion = $this->getFeatureDescs(new Criteria(), $con)->diff($featureDescs);
+
+ foreach ($this->featureDescsScheduledForDeletion as $featureDescRemoved) {
+ $featureDescRemoved->setFeature(null);
+ }
+
+ $this->collFeatureDescs = null;
+ foreach ($featureDescs as $featureDesc) {
+ $this->addFeatureDesc($featureDesc);
+ }
+
+ $this->collFeatureDescs = $featureDescs;
+ $this->collFeatureDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related FeatureDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related FeatureDesc objects.
+ * @throws PropelException
+ */
+ public function countFeatureDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collFeatureDescsPartial && !$this->isNew();
+ if (null === $this->collFeatureDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getFeatureDescs());
+ }
+ $query = FeatureDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeature($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collFeatureDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a FeatureDesc object to this object
+ * through the FeatureDesc foreign key attribute.
+ *
+ * @param FeatureDesc $l FeatureDesc
+ * @return Feature The current object (for fluent API support)
+ */
+ public function addFeatureDesc(FeatureDesc $l)
+ {
+ if ($this->collFeatureDescs === null) {
+ $this->initFeatureDescs();
+ $this->collFeatureDescsPartial = true;
+ }
+ if (!$this->collFeatureDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureDesc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureDesc $featureDesc The featureDesc object to add.
+ */
+ protected function doAddFeatureDesc($featureDesc)
+ {
+ $this->collFeatureDescs[]= $featureDesc;
+ $featureDesc->setFeature($this);
+ }
+
+ /**
+ * @param FeatureDesc $featureDesc The featureDesc object to remove.
+ */
+ public function removeFeatureDesc($featureDesc)
+ {
+ if ($this->getFeatureDescs()->contains($featureDesc)) {
+ $this->collFeatureDescs->remove($this->collFeatureDescs->search($featureDesc));
+ if (null === $this->featureDescsScheduledForDeletion) {
+ $this->featureDescsScheduledForDeletion = clone $this->collFeatureDescs;
+ $this->featureDescsScheduledForDeletion->clear();
+ }
+ $this->featureDescsScheduledForDeletion[]= $featureDesc;
+ $featureDesc->setFeature(null);
+ }
+ }
+
+ /**
+ * Clears out the collFeatureProds collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureProds()
+ */
+ public function clearFeatureProds()
+ {
+ $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized
+ $this->collFeatureProdsPartial = null;
+ }
+
+ /**
+ * reset is the collFeatureProds collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialFeatureProds($v = true)
+ {
+ $this->collFeatureProdsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureProds collection.
+ *
+ * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureProds($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureProds && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureProds = new PropelObjectCollection();
+ $this->collFeatureProds->setModel('FeatureProd');
+ }
+
+ /**
+ * Gets an array of FeatureProd objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this Feature is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
+ * @throws PropelException
+ */
+ public function getFeatureProds($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collFeatureProdsPartial && !$this->isNew();
+ if (null === $this->collFeatureProds || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureProds) {
+ // return empty collection
+ $this->initFeatureProds();
+ } else {
+ $collFeatureProds = FeatureProdQuery::create(null, $criteria)
+ ->filterByFeature($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) {
+ $this->initFeatureProds(false);
+
+ foreach($collFeatureProds as $obj) {
+ if (false == $this->collFeatureProds->contains($obj)) {
+ $this->collFeatureProds->append($obj);
+ }
+ }
+
+ $this->collFeatureProdsPartial = true;
+ }
+
+ return $collFeatureProds;
+ }
+
+ if($partial && $this->collFeatureProds) {
+ foreach($this->collFeatureProds as $obj) {
+ if($obj->isNew()) {
+ $collFeatureProds[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureProds = $collFeatureProds;
+ $this->collFeatureProdsPartial = false;
+ }
+ }
+
+ return $this->collFeatureProds;
+ }
+
+ /**
+ * Sets a collection of FeatureProd objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $featureProds A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null)
+ {
+ $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds);
+
+ foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) {
+ $featureProdRemoved->setFeature(null);
+ }
+
+ $this->collFeatureProds = null;
+ foreach ($featureProds as $featureProd) {
+ $this->addFeatureProd($featureProd);
+ }
+
+ $this->collFeatureProds = $featureProds;
+ $this->collFeatureProdsPartial = false;
+ }
+
+ /**
+ * Returns the number of related FeatureProd objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related FeatureProd objects.
+ * @throws PropelException
+ */
+ public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collFeatureProdsPartial && !$this->isNew();
+ if (null === $this->collFeatureProds || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureProds) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getFeatureProds());
+ }
+ $query = FeatureProdQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeature($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collFeatureProds);
+ }
+ }
+
+ /**
+ * Method called to associate a FeatureProd object to this object
+ * through the FeatureProd foreign key attribute.
+ *
+ * @param FeatureProd $l FeatureProd
+ * @return Feature The current object (for fluent API support)
+ */
+ public function addFeatureProd(FeatureProd $l)
+ {
+ if ($this->collFeatureProds === null) {
+ $this->initFeatureProds();
+ $this->collFeatureProdsPartial = true;
+ }
+ if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureProd($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureProd $featureProd The featureProd object to add.
+ */
+ protected function doAddFeatureProd($featureProd)
+ {
+ $this->collFeatureProds[]= $featureProd;
+ $featureProd->setFeature($this);
+ }
+
+ /**
+ * @param FeatureProd $featureProd The featureProd object to remove.
+ */
+ public function removeFeatureProd($featureProd)
+ {
+ if ($this->getFeatureProds()->contains($featureProd)) {
+ $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd));
+ if (null === $this->featureProdsScheduledForDeletion) {
+ $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds;
+ $this->featureProdsScheduledForDeletion->clear();
+ }
+ $this->featureProdsScheduledForDeletion[]= $featureProd;
+ $featureProd->setFeature(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Feature is new, it will return
+ * an empty collection; or if this Feature has previously
+ * been saved, it will retrieve related FeatureProds from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Feature.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
+ */
+ public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = FeatureProdQuery::create(null, $criteria);
+ $query->joinWith('FeatureAv', $join_behavior);
+
+ return $this->getFeatureProds($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Feature is new, it will return
+ * an empty collection; or if this Feature has previously
+ * been saved, it will retrieve related FeatureProds from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Feature.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
+ */
+ public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = FeatureProdQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getFeatureProds($query, $con);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ 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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeaturePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAv.php b/core/lib/Thelia/Model/om/BaseFeatureAv.php
new file mode 100644
index 000000000..1b8704563
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureAv.php
@@ -0,0 +1,1704 @@
+id;
+ }
+
+ /**
+ * Get the [feature_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureId()
+ {
+ return $this->feature_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return FeatureAv The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureAvPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [feature_id] column.
+ *
+ * @param int $v new value
+ * @return FeatureAv The current object (for fluent API support)
+ */
+ public function setFeatureId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_id !== $v) {
+ $this->feature_id = $v;
+ $this->modifiedColumns[] = FeatureAvPeer::FEATURE_ID;
+ }
+
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
+
+ return $this;
+ } // setFeatureId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FeatureAv The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = FeatureAvPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FeatureAv The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = FeatureAvPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->feature_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = FeatureAvPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating FeatureAv object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = FeatureAvPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFeature = null;
+ $this->collFeatureAvDescs = null;
+
+ $this->collFeatureProds = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FeatureAvQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureAvPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->featureAvDescsScheduledForDeletion !== null) {
+ if (!$this->featureAvDescsScheduledForDeletion->isEmpty()) {
+ FeatureAvDescQuery::create()
+ ->filterByPrimaryKeys($this->featureAvDescsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureAvDescsScheduledForDeletion = null;
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureAvPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureAvPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureAvPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FeatureAvPeer::FEATURE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FEATURE_ID`';
+ }
+ if ($this->isColumnModified(FeatureAvPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(FeatureAvPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `feature_av` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`FEATURE_ID`':
+ $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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 = FeatureAvPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ 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());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getFeatureId();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureAv'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureAv'][$this->getPrimaryKey()] = true;
+ $keys = FeatureAvPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFeatureId(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collFeatureAvDescs) {
+ $result['FeatureAvDescs'] = $this->collFeatureAvDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setFeatureId($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = FeatureAvPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureAvPeer::ID)) $criteria->add(FeatureAvPeer::ID, $this->id);
+ if ($this->isColumnModified(FeatureAvPeer::FEATURE_ID)) $criteria->add(FeatureAvPeer::FEATURE_ID, $this->feature_id);
+ if ($this->isColumnModified(FeatureAvPeer::CREATED_AT)) $criteria->add(FeatureAvPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeatureAvPeer::UPDATED_AT)) $criteria->add(FeatureAvPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
+ $criteria->add(FeatureAvPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of FeatureAv (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFeatureId($this->getFeatureId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return FeatureAv Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return FeatureAvPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FeatureAvPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Feature object.
+ *
+ * @param Feature $v
+ * @return FeatureAv 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->addFeatureAv($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->addFeatureAvs($this);
+ */
+ }
+
+ return $this->aFeature;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('FeatureAvDesc' == $relationName) {
+ $this->initFeatureAvDescs();
+ }
+ if ('FeatureProd' == $relationName) {
+ $this->initFeatureProds();
+ }
+ }
+
+ /**
+ * 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 PropelObjectCollection|FeatureAvDesc[] List of FeatureAvDesc objects
+ * @throws PropelException
+ */
+ 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);
+
+ 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->collFeatureAvDescs;
+ }
+
+ /**
+ * 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 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 countFeatureAvDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $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();
+ }
+
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->feature_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($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->collFeatureAvDescs instanceof PropelCollection) {
+ $this->collFeatureAvDescs->clearIterator();
+ }
+ $this->collFeatureAvDescs = null;
+ if ($this->collFeatureProds instanceof PropelCollection) {
+ $this->collFeatureProds->clearIterator();
+ }
+ $this->collFeatureProds = null;
+ $this->aFeature = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureAvPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php b/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php
new file mode 100644
index 000000000..d01569462
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php
@@ -0,0 +1,1150 @@
+id;
+ }
+
+ /**
+ * Get the [feature_av_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureAvId()
+ {
+ return $this->feature_av_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return FeatureAvDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureAvDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [feature_av_id] column.
+ *
+ * @param int $v new value
+ * @return FeatureAvDesc The current object (for fluent API support)
+ */
+ public function setFeatureAvId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_av_id !== $v) {
+ $this->feature_av_id = $v;
+ $this->modifiedColumns[] = FeatureAvDescPeer::FEATURE_AV_ID;
+ }
+
+ if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) {
+ $this->aFeatureAv = null;
+ }
+
+
+ return $this;
+ } // setFeatureAvId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return FeatureAvDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = FeatureAvDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return FeatureAvDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = FeatureAvDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return FeatureAvDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = FeatureAvDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return FeatureAvDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = FeatureAvDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->feature_av_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = FeatureAvDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating FeatureAvDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aFeatureAv !== null && $this->feature_av_id !== $this->aFeatureAv->getId()) {
+ $this->aFeatureAv = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = FeatureAvDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFeatureAv = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FeatureAvDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureAvDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureAvDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureAvDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureAvDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FeatureAvDescPeer::FEATURE_AV_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FEATURE_AV_ID`';
+ }
+ if ($this->isColumnModified(FeatureAvDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(FeatureAvDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(FeatureAvDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(FeatureAvDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `feature_av_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`FEATURE_AV_ID`':
+ $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureAvDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getFeatureAvId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureAvDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureAvDesc'][$this->getPrimaryKey()] = true;
+ $keys = FeatureAvDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFeatureAvId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aFeatureAv) {
+ $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureAvDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setFeatureAvId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = FeatureAvDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFeatureAvId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(FeatureAvDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureAvDescPeer::ID)) $criteria->add(FeatureAvDescPeer::ID, $this->id);
+ if ($this->isColumnModified(FeatureAvDescPeer::FEATURE_AV_ID)) $criteria->add(FeatureAvDescPeer::FEATURE_AV_ID, $this->feature_av_id);
+ if ($this->isColumnModified(FeatureAvDescPeer::LANG)) $criteria->add(FeatureAvDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(FeatureAvDescPeer::TITLE)) $criteria->add(FeatureAvDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(FeatureAvDescPeer::DESCRIPTION)) $criteria->add(FeatureAvDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(FeatureAvDescPeer::CHAPO)) $criteria->add(FeatureAvDescPeer::CHAPO, $this->chapo);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(FeatureAvDescPeer::DATABASE_NAME);
+ $criteria->add(FeatureAvDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of FeatureAvDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFeatureAvId($this->getFeatureAvId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return FeatureAvDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return FeatureAvDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FeatureAvDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a FeatureAv object.
+ *
+ * @param FeatureAv $v
+ * @return FeatureAvDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeatureAv(FeatureAv $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->feature_av_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aFeatureAv = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureAvDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php
new file mode 100644
index 000000000..6799cdd18
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php
@@ -0,0 +1,1027 @@
+ array ('Id', 'FeatureAvId', 'Lang', 'Title', 'Description', 'Chapo', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'featureAvId', 'lang', 'title', 'description', 'chapo', ),
+ BasePeer::TYPE_COLNAME => array (FeatureAvDescPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, FeatureAvDescPeer::LANG, FeatureAvDescPeer::TITLE, FeatureAvDescPeer::DESCRIPTION, FeatureAvDescPeer::CHAPO, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FEATURE_AV_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'feature_av_id', 'lang', 'title', 'description', 'chapo', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. FeatureAvDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FeatureAvId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'featureAvId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, ),
+ BasePeer::TYPE_COLNAME => array (FeatureAvDescPeer::ID => 0, FeatureAvDescPeer::FEATURE_AV_ID => 1, FeatureAvDescPeer::LANG => 2, FeatureAvDescPeer::TITLE => 3, FeatureAvDescPeer::DESCRIPTION => 4, FeatureAvDescPeer::CHAPO => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FEATURE_AV_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'feature_av_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = FeatureAvDescPeer::getFieldNames($toType);
+ $key = isset(FeatureAvDescPeer::$fieldKeys[$fromType][$name]) ? FeatureAvDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeatureAvDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, FeatureAvDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return FeatureAvDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. FeatureAvDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FeatureAvDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureAvDescPeer::ID);
+ $criteria->addSelectColumn(FeatureAvDescPeer::FEATURE_AV_ID);
+ $criteria->addSelectColumn(FeatureAvDescPeer::LANG);
+ $criteria->addSelectColumn(FeatureAvDescPeer::TITLE);
+ $criteria->addSelectColumn(FeatureAvDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(FeatureAvDescPeer::CHAPO);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_AV_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return FeatureAvDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = FeatureAvDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return FeatureAvDescPeer::populateObjects(FeatureAvDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FeatureAvDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param FeatureAvDesc $obj A FeatureAvDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ FeatureAvDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A FeatureAvDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof FeatureAvDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FeatureAvDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FeatureAvDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return FeatureAvDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(FeatureAvDescPeer::$instances[$key])) {
+ return FeatureAvDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FeatureAvDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to feature_av_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = FeatureAvDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FeatureAvDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FeatureAvDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureAvDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureAvDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FeatureAvDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FeatureAvDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + FeatureAvDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureAvDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FeatureAvDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(FeatureAvDescPeer::DATABASE_NAME)->getTable(FeatureAvDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFeatureAvDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFeatureAvDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureAvDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FeatureAvDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureAvDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureAvDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from FeatureAvDesc object
+ }
+
+ if ($criteria->containsKey(FeatureAvDescPeer::ID) && $criteria->keyContainsValue(FeatureAvDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureAvDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a FeatureAvDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureAvDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FeatureAvDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FeatureAvDescPeer::ID);
+ $value = $criteria->remove(FeatureAvDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(FeatureAvDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FeatureAvDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is FeatureAvDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the feature_av_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ FeatureAvDescPeer::clearInstancePool();
+ FeatureAvDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureAvDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureAvDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(FeatureAvDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ FeatureAvDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given FeatureAvDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param FeatureAvDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(FeatureAvDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FeatureAvDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(FeatureAvDescPeer::DATABASE_NAME, FeatureAvDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return FeatureAvDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = FeatureAvDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(FeatureAvDescPeer::DATABASE_NAME);
+ $criteria->add(FeatureAvDescPeer::ID, $pk);
+
+ $v = FeatureAvDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return FeatureAvDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(FeatureAvDescPeer::DATABASE_NAME);
+ $criteria->add(FeatureAvDescPeer::ID, $pks, Criteria::IN);
+ $objs = FeatureAvDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseFeatureAvDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFeatureAvDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php
new file mode 100644
index 000000000..001058925
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php
@@ -0,0 +1,519 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return FeatureAvDesc|FeatureAvDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureAvDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureAvDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `FEATURE_AV_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO` FROM `feature_av_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new FeatureAvDesc();
+ $obj->hydrate($row);
+ FeatureAvDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureAvDesc|FeatureAvDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|FeatureAvDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureAvDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureAvDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FeatureAvDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_av_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureAvId(1234); // WHERE feature_av_id = 1234
+ * $query->filterByFeatureAvId(array(12, 34)); // WHERE feature_av_id IN (12, 34)
+ * $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id > 12
+ *
+ *
+ * @see filterByFeatureAv()
+ *
+ * @param mixed $featureAvId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAvId($featureAvId = null, $comparison = null)
+ {
+ if (is_array($featureAvId)) {
+ $useMinMax = false;
+ if (isset($featureAvId['min'])) {
+ $this->addUsingAlias(FeatureAvDescPeer::FEATURE_AV_ID, $featureAvId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureAvId['max'])) {
+ $this->addUsingAlias(FeatureAvDescPeer::FEATURE_AV_ID, $featureAvId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvDescPeer::FEATURE_AV_ID, $featureAvId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvDescPeer::CHAPO, $chapo, $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 FeatureAvDescQuery 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(FeatureAvDescPeer::FEATURE_AV_ID, $featureAv->getId(), $comparison);
+ } elseif ($featureAv instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureAvDescPeer::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 FeatureAvDescQuery 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');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param FeatureAvDesc $featureAvDesc Object to remove from the list of results
+ *
+ * @return FeatureAvDescQuery The current query, for fluid interface
+ */
+ public function prune($featureAvDesc = null)
+ {
+ if ($featureAvDesc) {
+ $this->addUsingAlias(FeatureAvDescPeer::ID, $featureAvDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php
new file mode 100644
index 000000000..e8e9232dd
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php
@@ -0,0 +1,1025 @@
+ array ('Id', 'FeatureId', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'featureId', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (FeatureAvPeer::ID, FeatureAvPeer::FEATURE_ID, FeatureAvPeer::CREATED_AT, FeatureAvPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FEATURE_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'feature_id', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. FeatureAvPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FeatureId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'featureId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ BasePeer::TYPE_COLNAME => array (FeatureAvPeer::ID => 0, FeatureAvPeer::FEATURE_ID => 1, FeatureAvPeer::CREATED_AT => 2, FeatureAvPeer::UPDATED_AT => 3, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FEATURE_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'feature_id' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = FeatureAvPeer::getFieldNames($toType);
+ $key = isset(FeatureAvPeer::$fieldKeys[$fromType][$name]) ? FeatureAvPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeatureAvPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, FeatureAvPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return FeatureAvPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. FeatureAvPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FeatureAvPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureAvPeer::ID);
+ $criteria->addSelectColumn(FeatureAvPeer::FEATURE_ID);
+ $criteria->addSelectColumn(FeatureAvPeer::CREATED_AT);
+ $criteria->addSelectColumn(FeatureAvPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return FeatureAv
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = FeatureAvPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return FeatureAvPeer::populateObjects(FeatureAvPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FeatureAvPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param FeatureAv $obj A FeatureAv object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ FeatureAvPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A FeatureAv object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof FeatureAv) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FeatureAv object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FeatureAvPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return FeatureAv Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(FeatureAvPeer::$instances[$key])) {
+ return FeatureAvPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FeatureAvPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to feature_av
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in FeatureAvDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = FeatureAvPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FeatureAvPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FeatureAvPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureAvPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureAv object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FeatureAvPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + FeatureAvPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureAvPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FeatureAvPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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(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::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 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
+ * @return array Array of FeatureAv 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(FeatureAvPeer::DATABASE_NAME);
+ }
+
+ FeatureAvPeer::addSelectColumns($criteria);
+ $startcol = FeatureAvPeer::NUM_HYDRATE_COLUMNS;
+ FeaturePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::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 = 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 (FeatureAv) to $obj2 (Feature)
+ $obj2->addFeatureAv($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(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::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 FeatureAv 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 FeatureAv 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(FeatureAvPeer::DATABASE_NAME);
+ }
+
+ FeatureAvPeer::addSelectColumns($criteria);
+ $startcol2 = FeatureAvPeer::NUM_HYDRATE_COLUMNS;
+
+ FeaturePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::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 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 (FeatureAv) to the collection in $obj2 (Feature)
+ $obj2->addFeatureAv($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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(FeatureAvPeer::DATABASE_NAME)->getTable(FeatureAvPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFeatureAvPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFeatureAvPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureAvTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FeatureAvPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureAv or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureAv object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from FeatureAv object
+ }
+
+ if ($criteria->containsKey(FeatureAvPeer::ID) && $criteria->keyContainsValue(FeatureAvPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureAvPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a FeatureAv or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureAv object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FeatureAvPeer::ID);
+ $value = $criteria->remove(FeatureAvPeer::ID);
+ if ($value) {
+ $selectCriteria->add(FeatureAvPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FeatureAvPeer::TABLE_NAME);
+ }
+
+ } else { // $values is FeatureAv object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the feature_av table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ FeatureAvPeer::clearInstancePool();
+ FeatureAvPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureAv or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureAv object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(FeatureAvPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ FeatureAvPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given FeatureAv object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param FeatureAv $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(FeatureAvPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FeatureAvPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(FeatureAvPeer::DATABASE_NAME, FeatureAvPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return FeatureAv
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = FeatureAvPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
+ $criteria->add(FeatureAvPeer::ID, $pk);
+
+ $v = FeatureAvPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return FeatureAv[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME);
+ $criteria->add(FeatureAvPeer::ID, $pks, Criteria::IN);
+ $objs = FeatureAvPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseFeatureAvPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFeatureAvPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php
new file mode 100644
index 000000000..56948a5d2
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php
@@ -0,0 +1,639 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return FeatureAv|FeatureAv[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureAvPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureAv A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `FEATURE_ID`, `CREATED_AT`, `UPDATED_AT` FROM `feature_av` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new FeatureAv();
+ $obj->hydrate($row);
+ FeatureAvPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureAv|FeatureAv[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|FeatureAv[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureAvPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureAvPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FeatureAvPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureId(1234); // WHERE feature_id = 1234
+ * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34)
+ * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
+ *
+ *
+ * @see filterByFeature()
+ *
+ * @param mixed $featureId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByFeatureId($featureId = null, $comparison = null)
+ {
+ if (is_array($featureId)) {
+ $useMinMax = false;
+ if (isset($featureId['min'])) {
+ $this->addUsingAlias(FeatureAvPeer::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureId['max'])) {
+ $this->addUsingAlias(FeatureAvPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvPeer::FEATURE_ID, $featureId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeatureAvPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeatureAvPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ 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 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 filterByFeatureAvDesc($featureAvDesc, $comparison = null)
+ {
+ if ($featureAvDesc instanceof FeatureAvDesc) {
+ return $this
+ ->addUsingAlias(FeatureAvPeer::ID, $featureAvDesc->getFeatureAvId(), $comparison);
+ } elseif ($featureAvDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useFeatureAvDescQuery()
+ ->filterByPrimaryKeys($featureAvDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureAvDesc() only accepts arguments of type FeatureAvDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureAvDesc 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 joinFeatureAvDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureAvDesc');
+
+ // 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, 'FeatureAvDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureAvDesc relation FeatureAvDesc 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\FeatureAvDescQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureAvDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureAvDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureAvDesc', '\Thelia\Model\FeatureAvDescQuery');
+ }
+
+ /**
+ * Filter the query by a related FeatureProd object
+ *
+ * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFeatureProd($featureProd, $comparison = null)
+ {
+ if ($featureProd instanceof FeatureProd) {
+ return $this
+ ->addUsingAlias(FeatureAvPeer::ID, $featureProd->getFeatureAvId(), $comparison);
+ } elseif ($featureProd instanceof PropelObjectCollection) {
+ return $this
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureProd relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureProd');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureProd');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureProd relation FeatureProd object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFeatureProd($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param FeatureAv $featureAv Object to remove from the list of results
+ *
+ * @return FeatureAvQuery The current query, for fluid interface
+ */
+ public function prune($featureAv = null)
+ {
+ if ($featureAv) {
+ $this->addUsingAlias(FeatureAvPeer::ID, $featureAv->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategory.php b/core/lib/Thelia/Model/om/BaseFeatureCategory.php
new file mode 100644
index 000000000..098fe90cb
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureCategory.php
@@ -0,0 +1,1238 @@
+id;
+ }
+
+ /**
+ * Get the [feature_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureId()
+ {
+ return $this->feature_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return FeatureCategory The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureCategoryPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [feature_id] column.
+ *
+ * @param int $v new value
+ * @return FeatureCategory The current object (for fluent API support)
+ */
+ public function setFeatureId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_id !== $v) {
+ $this->feature_id = $v;
+ $this->modifiedColumns[] = FeatureCategoryPeer::FEATURE_ID;
+ }
+
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
+
+ return $this;
+ } // setFeatureId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return FeatureCategory The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = FeatureCategoryPeer::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FeatureCategory The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = FeatureCategoryPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FeatureCategory The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = FeatureCategoryPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->feature_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->category_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating FeatureCategory object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = FeatureCategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ $this->aFeature = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FeatureCategoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureCategoryPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureCategoryPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureCategoryPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureCategoryPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FeatureCategoryPeer::FEATURE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FEATURE_ID`';
+ }
+ if ($this->isColumnModified(FeatureCategoryPeer::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`';
+ }
+ if ($this->isColumnModified(FeatureCategoryPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `feature_category` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`FEATURE_ID`':
+ $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
+ break;
+ case '`CATEGORY_ID`':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getFeatureId();
+ break;
+ case 2:
+ return $this->getCategoryId();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()] = true;
+ $keys = FeatureCategoryPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFeatureId(),
+ $keys[2] => $this->getCategoryId(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setFeatureId($value);
+ break;
+ case 2:
+ $this->setCategoryId($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = FeatureCategoryPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureCategoryPeer::ID)) $criteria->add(FeatureCategoryPeer::ID, $this->id);
+ if ($this->isColumnModified(FeatureCategoryPeer::FEATURE_ID)) $criteria->add(FeatureCategoryPeer::FEATURE_ID, $this->feature_id);
+ if ($this->isColumnModified(FeatureCategoryPeer::CATEGORY_ID)) $criteria->add(FeatureCategoryPeer::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(FeatureCategoryPeer::CREATED_AT)) $criteria->add(FeatureCategoryPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) $criteria->add(FeatureCategoryPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME);
+ $criteria->add(FeatureCategoryPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of FeatureCategory (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFeatureId($this->getFeatureId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return FeatureCategory Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return FeatureCategoryPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FeatureCategoryPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return FeatureCategory 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->addFeatureCategory($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->addFeatureCategorys($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a Feature object.
+ *
+ * @param Feature $v
+ * @return FeatureCategory 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->feature_id = null;
+ $this->category_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ $this->aFeature = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureCategoryPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php
new file mode 100644
index 000000000..bbd78d2a6
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php
@@ -0,0 +1,1416 @@
+ array ('Id', 'FeatureId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'featureId', 'categoryId', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (FeatureCategoryPeer::ID, FeatureCategoryPeer::FEATURE_ID, FeatureCategoryPeer::CATEGORY_ID, FeatureCategoryPeer::CREATED_AT, FeatureCategoryPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FEATURE_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'feature_id', 'category_id', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. FeatureCategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FeatureId' => 1, 'CategoryId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'featureId' => 1, 'categoryId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (FeatureCategoryPeer::ID => 0, FeatureCategoryPeer::FEATURE_ID => 1, FeatureCategoryPeer::CATEGORY_ID => 2, FeatureCategoryPeer::CREATED_AT => 3, FeatureCategoryPeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FEATURE_ID' => 1, 'CATEGORY_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'feature_id' => 1, 'category_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = FeatureCategoryPeer::getFieldNames($toType);
+ $key = isset(FeatureCategoryPeer::$fieldKeys[$fromType][$name]) ? FeatureCategoryPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeatureCategoryPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, FeatureCategoryPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return FeatureCategoryPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. FeatureCategoryPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FeatureCategoryPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureCategoryPeer::ID);
+ $criteria->addSelectColumn(FeatureCategoryPeer::FEATURE_ID);
+ $criteria->addSelectColumn(FeatureCategoryPeer::CATEGORY_ID);
+ $criteria->addSelectColumn(FeatureCategoryPeer::CREATED_AT);
+ $criteria->addSelectColumn(FeatureCategoryPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return FeatureCategory
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = FeatureCategoryPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return FeatureCategoryPeer::populateObjects(FeatureCategoryPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FeatureCategoryPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param FeatureCategory $obj A FeatureCategory object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ FeatureCategoryPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A FeatureCategory object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof FeatureCategory) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FeatureCategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FeatureCategoryPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return FeatureCategory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(FeatureCategoryPeer::$instances[$key])) {
+ return FeatureCategoryPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FeatureCategoryPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to feature_category
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = FeatureCategoryPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FeatureCategoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureCategoryPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureCategory object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FeatureCategoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureCategoryPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FeatureCategoryPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(FeatureCategoryPeer::DATABASE_NAME)->getTable(FeatureCategoryPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFeatureCategoryPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFeatureCategoryPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureCategoryTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FeatureCategoryPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureCategory or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureCategory object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from FeatureCategory object
+ }
+
+ if ($criteria->containsKey(FeatureCategoryPeer::ID) && $criteria->keyContainsValue(FeatureCategoryPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureCategoryPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a FeatureCategory or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureCategory object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FeatureCategoryPeer::ID);
+ $value = $criteria->remove(FeatureCategoryPeer::ID);
+ if ($value) {
+ $selectCriteria->add(FeatureCategoryPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME);
+ }
+
+ } else { // $values is FeatureCategory object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the feature_category table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ FeatureCategoryPeer::clearInstancePool();
+ FeatureCategoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ FeatureCategoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given FeatureCategory object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param FeatureCategory $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(FeatureCategoryPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FeatureCategoryPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(FeatureCategoryPeer::DATABASE_NAME, FeatureCategoryPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return FeatureCategory
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = FeatureCategoryPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME);
+ $criteria->add(FeatureCategoryPeer::ID, $pk);
+
+ $v = FeatureCategoryPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return FeatureCategory[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME);
+ $criteria->add(FeatureCategoryPeer::ID, $pks, Criteria::IN);
+ $objs = FeatureCategoryPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseFeatureCategoryPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFeatureCategoryPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php
new file mode 100644
index 000000000..262bd682a
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php
@@ -0,0 +1,609 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return FeatureCategory|FeatureCategory[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureCategoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureCategory A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `FEATURE_ID`, `CATEGORY_ID`, `CREATED_AT`, `UPDATED_AT` FROM `feature_category` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new FeatureCategory();
+ $obj->hydrate($row);
+ FeatureCategoryPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureCategory|FeatureCategory[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|FeatureCategory[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return FeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureCategoryPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return FeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureCategoryPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FeatureCategoryPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureId(1234); // WHERE feature_id = 1234
+ * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34)
+ * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
+ *
+ *
+ * @see filterByFeature()
+ *
+ * @param mixed $featureId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByFeatureId($featureId = null, $comparison = null)
+ {
+ if (is_array($featureId)) {
+ $useMinMax = false;
+ if (isset($featureId['min'])) {
+ $this->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureId['max'])) {
+ $this->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $featureId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 FeatureCategoryQuery 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(FeatureCategoryPeer::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureCategoryPeer::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 FeatureCategoryQuery 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 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 FeatureCategoryQuery 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(FeatureCategoryPeer::FEATURE_ID, $feature->getId(), $comparison);
+ } elseif ($feature instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureCategoryPeer::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 FeatureCategoryQuery 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
+ *
+ * @param FeatureCategory $featureCategory Object to remove from the list of results
+ *
+ * @return FeatureCategoryQuery The current query, for fluid interface
+ */
+ public function prune($featureCategory = null)
+ {
+ if ($featureCategory) {
+ $this->addUsingAlias(FeatureCategoryPeer::ID, $featureCategory->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureDesc.php b/core/lib/Thelia/Model/om/BaseFeatureDesc.php
new file mode 100644
index 000000000..f33be3c8f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureDesc.php
@@ -0,0 +1,1320 @@
+id;
+ }
+
+ /**
+ * Get the [feature_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureId()
+ {
+ return $this->feature_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return FeatureDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [feature_id] column.
+ *
+ * @param int $v new value
+ * @return FeatureDesc The current object (for fluent API support)
+ */
+ public function setFeatureId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_id !== $v) {
+ $this->feature_id = $v;
+ $this->modifiedColumns[] = FeatureDescPeer::FEATURE_ID;
+ }
+
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
+
+ return $this;
+ } // setFeatureId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return FeatureDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = FeatureDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return FeatureDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = FeatureDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return FeatureDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = FeatureDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return FeatureDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = FeatureDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FeatureDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = FeatureDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FeatureDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = FeatureDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->feature_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = FeatureDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating FeatureDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = FeatureDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFeature = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FeatureDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FeatureDescPeer::FEATURE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FEATURE_ID`';
+ }
+ if ($this->isColumnModified(FeatureDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(FeatureDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(FeatureDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(FeatureDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(FeatureDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(FeatureDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `feature_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`FEATURE_ID`':
+ $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getFeatureId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureDesc'][$this->getPrimaryKey()] = true;
+ $keys = FeatureDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFeatureId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setFeatureId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = FeatureDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(FeatureDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureDescPeer::ID)) $criteria->add(FeatureDescPeer::ID, $this->id);
+ if ($this->isColumnModified(FeatureDescPeer::FEATURE_ID)) $criteria->add(FeatureDescPeer::FEATURE_ID, $this->feature_id);
+ if ($this->isColumnModified(FeatureDescPeer::LANG)) $criteria->add(FeatureDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(FeatureDescPeer::TITLE)) $criteria->add(FeatureDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(FeatureDescPeer::DESCRIPTION)) $criteria->add(FeatureDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(FeatureDescPeer::CHAPO)) $criteria->add(FeatureDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(FeatureDescPeer::CREATED_AT)) $criteria->add(FeatureDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeatureDescPeer::UPDATED_AT)) $criteria->add(FeatureDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(FeatureDescPeer::DATABASE_NAME);
+ $criteria->add(FeatureDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of FeatureDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFeatureId($this->getFeatureId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return FeatureDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return FeatureDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FeatureDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Feature object.
+ *
+ * @param Feature $v
+ * @return FeatureDesc 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->feature_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aFeature = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureDescPeer.php b/core/lib/Thelia/Model/om/BaseFeatureDescPeer.php
new file mode 100644
index 000000000..1557012c2
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureDescPeer.php
@@ -0,0 +1,1037 @@
+ array ('Id', 'FeatureId', 'Lang', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'featureId', 'lang', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (FeatureDescPeer::ID, FeatureDescPeer::FEATURE_ID, FeatureDescPeer::LANG, FeatureDescPeer::TITLE, FeatureDescPeer::DESCRIPTION, FeatureDescPeer::CHAPO, FeatureDescPeer::CREATED_AT, FeatureDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FEATURE_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'feature_id', 'lang', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. FeatureDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FeatureId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'featureId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (FeatureDescPeer::ID => 0, FeatureDescPeer::FEATURE_ID => 1, FeatureDescPeer::LANG => 2, FeatureDescPeer::TITLE => 3, FeatureDescPeer::DESCRIPTION => 4, FeatureDescPeer::CHAPO => 5, FeatureDescPeer::CREATED_AT => 6, FeatureDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FEATURE_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'feature_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = FeatureDescPeer::getFieldNames($toType);
+ $key = isset(FeatureDescPeer::$fieldKeys[$fromType][$name]) ? FeatureDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeatureDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, FeatureDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return FeatureDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. FeatureDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FeatureDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureDescPeer::ID);
+ $criteria->addSelectColumn(FeatureDescPeer::FEATURE_ID);
+ $criteria->addSelectColumn(FeatureDescPeer::LANG);
+ $criteria->addSelectColumn(FeatureDescPeer::TITLE);
+ $criteria->addSelectColumn(FeatureDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(FeatureDescPeer::CHAPO);
+ $criteria->addSelectColumn(FeatureDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(FeatureDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return FeatureDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = FeatureDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return FeatureDescPeer::populateObjects(FeatureDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FeatureDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param FeatureDesc $obj A FeatureDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ FeatureDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A FeatureDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof FeatureDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FeatureDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FeatureDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return FeatureDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(FeatureDescPeer::$instances[$key])) {
+ return FeatureDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FeatureDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to feature_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = FeatureDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FeatureDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FeatureDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FeatureDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FeatureDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + FeatureDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FeatureDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(FeatureDescPeer::DATABASE_NAME)->getTable(FeatureDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFeatureDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFeatureDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FeatureDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from FeatureDesc object
+ }
+
+ if ($criteria->containsKey(FeatureDescPeer::ID) && $criteria->keyContainsValue(FeatureDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a FeatureDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FeatureDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FeatureDescPeer::ID);
+ $value = $criteria->remove(FeatureDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(FeatureDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FeatureDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is FeatureDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the feature_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ FeatureDescPeer::clearInstancePool();
+ FeatureDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(FeatureDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ FeatureDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given FeatureDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param FeatureDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(FeatureDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FeatureDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(FeatureDescPeer::DATABASE_NAME, FeatureDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return FeatureDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = FeatureDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(FeatureDescPeer::DATABASE_NAME);
+ $criteria->add(FeatureDescPeer::ID, $pk);
+
+ $v = FeatureDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return FeatureDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(FeatureDescPeer::DATABASE_NAME);
+ $criteria->add(FeatureDescPeer::ID, $pks, Criteria::IN);
+ $objs = FeatureDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseFeatureDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFeatureDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php b/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php
new file mode 100644
index 000000000..bf5bc3372
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php
@@ -0,0 +1,613 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return FeatureDesc|FeatureDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `FEATURE_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `feature_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new FeatureDesc();
+ $obj->hydrate($row);
+ FeatureDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureDesc|FeatureDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|FeatureDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FeatureDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureId(1234); // WHERE feature_id = 1234
+ * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34)
+ * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
+ *
+ *
+ * @see filterByFeature()
+ *
+ * @param mixed $featureId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByFeatureId($featureId = null, $comparison = null)
+ {
+ if (is_array($featureId)) {
+ $useMinMax = false;
+ if (isset($featureId['min'])) {
+ $this->addUsingAlias(FeatureDescPeer::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureId['max'])) {
+ $this->addUsingAlias(FeatureDescPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureDescPeer::FEATURE_ID, $featureId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeatureDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeatureDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeatureDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeatureDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureDescPeer::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 FeatureDescQuery 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(FeatureDescPeer::FEATURE_ID, $feature->getId(), $comparison);
+ } elseif ($feature instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureDescPeer::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 FeatureDescQuery 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
+ *
+ * @param FeatureDesc $featureDesc Object to remove from the list of results
+ *
+ * @return FeatureDescQuery The current query, for fluid interface
+ */
+ public function prune($featureDesc = null)
+ {
+ if ($featureDesc) {
+ $this->addUsingAlias(FeatureDescPeer::ID, $featureDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeaturePeer.php b/core/lib/Thelia/Model/om/BaseFeaturePeer.php
new file mode 100644
index 000000000..b5d43299c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeaturePeer.php
@@ -0,0 +1,799 @@
+ array ('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'visible', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (FeaturePeer::ID, FeaturePeer::VISIBLE, FeaturePeer::POSITION, FeaturePeer::CREATED_AT, FeaturePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'visible', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. FeaturePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (FeaturePeer::ID => 0, FeaturePeer::VISIBLE => 1, FeaturePeer::POSITION => 2, FeaturePeer::CREATED_AT => 3, FeaturePeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = FeaturePeer::getFieldNames($toType);
+ $key = isset(FeaturePeer::$fieldKeys[$fromType][$name]) ? FeaturePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeaturePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, FeaturePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return FeaturePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. FeaturePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FeaturePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeaturePeer::ID);
+ $criteria->addSelectColumn(FeaturePeer::VISIBLE);
+ $criteria->addSelectColumn(FeaturePeer::POSITION);
+ $criteria->addSelectColumn(FeaturePeer::CREATED_AT);
+ $criteria->addSelectColumn(FeaturePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(FeaturePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Feature
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = FeaturePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return FeaturePeer::populateObjects(FeaturePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FeaturePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FeaturePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Feature $obj A Feature object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ FeaturePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Feature object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Feature) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Feature object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FeaturePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Feature Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(FeaturePeer::$instances[$key])) {
+ return FeaturePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FeaturePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to feature
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = FeaturePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FeaturePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FeaturePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeaturePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Feature object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FeaturePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + FeaturePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeaturePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FeaturePeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(FeaturePeer::DATABASE_NAME)->getTable(FeaturePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFeaturePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFeaturePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FeaturePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Feature or Criteria object.
+ *
+ * @param mixed $values Criteria or Feature object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Feature object
+ }
+
+ if ($criteria->containsKey(FeaturePeer::ID) && $criteria->keyContainsValue(FeaturePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeaturePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FeaturePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Feature or Criteria object.
+ *
+ * @param mixed $values Criteria or Feature object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FeaturePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FeaturePeer::ID);
+ $value = $criteria->remove(FeaturePeer::ID);
+ if ($value) {
+ $selectCriteria->add(FeaturePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FeaturePeer::TABLE_NAME);
+ }
+
+ } else { // $values is Feature object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FeaturePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the feature table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(FeaturePeer::TABLE_NAME, $con, FeaturePeer::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
+ // instances get re-added by the select statement contained therein).
+ FeaturePeer::clearInstancePool();
+ FeaturePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Feature or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Feature object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ FeaturePeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Feature) { // it's a model object
+ // invalidate the cache for this single object
+ FeaturePeer::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(FeaturePeer::DATABASE_NAME);
+ $criteria->add(FeaturePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ FeaturePeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FeaturePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ FeaturePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Feature object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Feature $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(FeaturePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FeaturePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(FeaturePeer::DATABASE_NAME, FeaturePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Feature
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = FeaturePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
+ $criteria->add(FeaturePeer::ID, $pk);
+
+ $v = FeaturePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Feature[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
+ $criteria->add(FeaturePeer::ID, $pks, Criteria::IN);
+ $objs = FeaturePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseFeaturePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFeaturePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFeatureProd.php b/core/lib/Thelia/Model/om/BaseFeatureProd.php
new file mode 100644
index 000000000..b38cf038a
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureProd.php
@@ -0,0 +1,1486 @@
+id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [feature_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureId()
+ {
+ return $this->feature_id;
+ }
+
+ /**
+ * Get the [feature_av_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureAvId()
+ {
+ return $this->feature_av_id;
+ }
+
+ /**
+ * Get the [default_utility] column value.
+ *
+ * @return string
+ */
+ public function getDefaultUtility()
+ {
+ return $this->default_utility;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return FeatureProd The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureProdPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return FeatureProd The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = FeatureProdPeer::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [feature_id] column.
+ *
+ * @param int $v new value
+ * @return FeatureProd The current object (for fluent API support)
+ */
+ public function setFeatureId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_id !== $v) {
+ $this->feature_id = $v;
+ $this->modifiedColumns[] = FeatureProdPeer::FEATURE_ID;
+ }
+
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
+
+ return $this;
+ } // setFeatureId()
+
+ /**
+ * Set the value of [feature_av_id] column.
+ *
+ * @param int $v new value
+ * @return FeatureProd The current object (for fluent API support)
+ */
+ public function setFeatureAvId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_av_id !== $v) {
+ $this->feature_av_id = $v;
+ $this->modifiedColumns[] = FeatureProdPeer::FEATURE_AV_ID;
+ }
+
+ if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) {
+ $this->aFeatureAv = null;
+ }
+
+
+ return $this;
+ } // setFeatureAvId()
+
+ /**
+ * Set the value of [default_utility] column.
+ *
+ * @param string $v new value
+ * @return FeatureProd The current object (for fluent API support)
+ */
+ public function setDefaultUtility($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->default_utility !== $v) {
+ $this->default_utility = $v;
+ $this->modifiedColumns[] = FeatureProdPeer::DEFAULT_UTILITY;
+ }
+
+
+ return $this;
+ } // setDefaultUtility()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return FeatureProd The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = FeatureProdPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FeatureProd The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = FeatureProdPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FeatureProd The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = FeatureProdPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->feature_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->feature_av_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->default_utility = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->position = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = FeatureProdPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating FeatureProd object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = FeatureProdPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFeatureAv = null;
+ $this->aFeature = null;
+ $this->aProduct = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FeatureProdQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureProdPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureProdPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureProdPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureProdPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FeatureProdPeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(FeatureProdPeer::FEATURE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FEATURE_ID`';
+ }
+ if ($this->isColumnModified(FeatureProdPeer::FEATURE_AV_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FEATURE_AV_ID`';
+ }
+ if ($this->isColumnModified(FeatureProdPeer::DEFAULT_UTILITY)) {
+ $modifiedColumns[':p' . $index++] = '`DEFAULT_UTILITY`';
+ }
+ if ($this->isColumnModified(FeatureProdPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(FeatureProdPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(FeatureProdPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `feature_prod` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`FEATURE_ID`':
+ $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
+ break;
+ case '`FEATURE_AV_ID`':
+ $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT);
+ break;
+ case '`DEFAULT_UTILITY`':
+ $stmt->bindValue($identifier, $this->default_utility, PDO::PARAM_STR);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureProdPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getProductId();
+ break;
+ case 2:
+ return $this->getFeatureId();
+ break;
+ case 3:
+ return $this->getFeatureAvId();
+ break;
+ case 4:
+ return $this->getDefaultUtility();
+ break;
+ case 5:
+ return $this->getPosition();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureProd'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureProd'][$this->getPrimaryKey()] = true;
+ $keys = FeatureProdPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getFeatureId(),
+ $keys[3] => $this->getFeatureAvId(),
+ $keys[4] => $this->getDefaultUtility(),
+ $keys[5] => $this->getPosition(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aFeatureAv) {
+ $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FeatureProdPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setProductId($value);
+ break;
+ case 2:
+ $this->setFeatureId($value);
+ break;
+ case 3:
+ $this->setFeatureAvId($value);
+ break;
+ case 4:
+ $this->setDefaultUtility($value);
+ break;
+ case 5:
+ $this->setPosition($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = FeatureProdPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setFeatureId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFeatureAvId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDefaultUtility($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureProdPeer::ID)) $criteria->add(FeatureProdPeer::ID, $this->id);
+ if ($this->isColumnModified(FeatureProdPeer::PRODUCT_ID)) $criteria->add(FeatureProdPeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(FeatureProdPeer::FEATURE_ID)) $criteria->add(FeatureProdPeer::FEATURE_ID, $this->feature_id);
+ if ($this->isColumnModified(FeatureProdPeer::FEATURE_AV_ID)) $criteria->add(FeatureProdPeer::FEATURE_AV_ID, $this->feature_av_id);
+ if ($this->isColumnModified(FeatureProdPeer::DEFAULT_UTILITY)) $criteria->add(FeatureProdPeer::DEFAULT_UTILITY, $this->default_utility);
+ if ($this->isColumnModified(FeatureProdPeer::POSITION)) $criteria->add(FeatureProdPeer::POSITION, $this->position);
+ if ($this->isColumnModified(FeatureProdPeer::CREATED_AT)) $criteria->add(FeatureProdPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeatureProdPeer::UPDATED_AT)) $criteria->add(FeatureProdPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME);
+ $criteria->add(FeatureProdPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of FeatureProd (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setFeatureId($this->getFeatureId());
+ $copyObj->setFeatureAvId($this->getFeatureAvId());
+ $copyObj->setDefaultUtility($this->getDefaultUtility());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return FeatureProd Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return FeatureProdPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FeatureProdPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a FeatureAv object.
+ *
+ * @param FeatureAv $v
+ * @return FeatureProd The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeatureAv(FeatureAv $v = null)
+ {
+ 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;
+ }
+
+
+ /**
+ * 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->addFeatureProds($this);
+ */
+ }
+
+ return $this->aFeatureAv;
+ }
+
+ /**
+ * Declares an association between this object and a Feature object.
+ *
+ * @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)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->feature_id = null;
+ $this->feature_av_id = null;
+ $this->default_utility = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aFeatureAv = null;
+ $this->aFeature = null;
+ $this->aProduct = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureProdPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php
new file mode 100644
index 000000000..235e9cefa
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php
@@ -0,0 +1,1778 @@
+ array ('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'DefaultUtility', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'featureId', 'featureAvId', 'defaultUtility', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (FeatureProdPeer::ID, FeatureProdPeer::PRODUCT_ID, FeatureProdPeer::FEATURE_ID, FeatureProdPeer::FEATURE_AV_ID, FeatureProdPeer::DEFAULT_UTILITY, FeatureProdPeer::POSITION, FeatureProdPeer::CREATED_AT, FeatureProdPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'DEFAULT_UTILITY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'feature_id', 'feature_av_id', 'default_utility', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. FeatureProdPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'DefaultUtility' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'defaultUtility' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (FeatureProdPeer::ID => 0, FeatureProdPeer::PRODUCT_ID => 1, FeatureProdPeer::FEATURE_ID => 2, FeatureProdPeer::FEATURE_AV_ID => 3, FeatureProdPeer::DEFAULT_UTILITY => 4, FeatureProdPeer::POSITION => 5, FeatureProdPeer::CREATED_AT => 6, FeatureProdPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'DEFAULT_UTILITY' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'default_utility' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = FeatureProdPeer::getFieldNames($toType);
+ $key = isset(FeatureProdPeer::$fieldKeys[$fromType][$name]) ? FeatureProdPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeatureProdPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, FeatureProdPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return FeatureProdPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. FeatureProdPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FeatureProdPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureProdPeer::ID);
+ $criteria->addSelectColumn(FeatureProdPeer::PRODUCT_ID);
+ $criteria->addSelectColumn(FeatureProdPeer::FEATURE_ID);
+ $criteria->addSelectColumn(FeatureProdPeer::FEATURE_AV_ID);
+ $criteria->addSelectColumn(FeatureProdPeer::DEFAULT_UTILITY);
+ $criteria->addSelectColumn(FeatureProdPeer::POSITION);
+ $criteria->addSelectColumn(FeatureProdPeer::CREATED_AT);
+ $criteria->addSelectColumn(FeatureProdPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_AV_ID');
+ $criteria->addSelectColumn($alias . '.DEFAULT_UTILITY');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return FeatureProd
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = FeatureProdPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return FeatureProdPeer::populateObjects(FeatureProdPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FeatureProdPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param FeatureProd $obj A FeatureProd object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ FeatureProdPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A FeatureProd object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof FeatureProd) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FeatureProd object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FeatureProdPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return FeatureProd Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(FeatureProdPeer::$instances[$key])) {
+ return FeatureProdPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FeatureProdPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to feature_prod
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = FeatureProdPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FeatureProdPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureProdPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureProd object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FeatureProdPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + FeatureProdPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureProdPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FeatureProdPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(FeatureProdPeer::DATABASE_NAME)->getTable(FeatureProdPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFeatureProdPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFeatureProdPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureProdTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FeatureProdPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureProd or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureProd object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from FeatureProd object
+ }
+
+ if ($criteria->containsKey(FeatureProdPeer::ID) && $criteria->keyContainsValue(FeatureProdPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureProdPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a FeatureProd or Criteria object.
+ *
+ * @param mixed $values Criteria or FeatureProd object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FeatureProdPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FeatureProdPeer::ID);
+ $value = $criteria->remove(FeatureProdPeer::ID);
+ if ($value) {
+ $selectCriteria->add(FeatureProdPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME);
+ }
+
+ } else { // $values is FeatureProd object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the feature_prod table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ FeatureProdPeer::clearInstancePool();
+ FeatureProdPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureProd or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureProd object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(FeatureProdPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ FeatureProdPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given FeatureProd object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param FeatureProd $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(FeatureProdPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FeatureProdPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(FeatureProdPeer::DATABASE_NAME, FeatureProdPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return FeatureProd
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = FeatureProdPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME);
+ $criteria->add(FeatureProdPeer::ID, $pk);
+
+ $v = FeatureProdPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return FeatureProd[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME);
+ $criteria->add(FeatureProdPeer::ID, $pks, Criteria::IN);
+ $objs = FeatureProdPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseFeatureProdPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFeatureProdPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php
new file mode 100644
index 000000000..d8a0daccb
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php
@@ -0,0 +1,815 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return FeatureProd|FeatureProd[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureProdPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureProd A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PRODUCT_ID`, `FEATURE_ID`, `FEATURE_AV_ID`, `DEFAULT_UTILITY`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `feature_prod` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new FeatureProd();
+ $obj->hydrate($row);
+ FeatureProdPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FeatureProd|FeatureProd[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|FeatureProd[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureProdPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureProdPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FeatureProdPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureId(1234); // WHERE feature_id = 1234
+ * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34)
+ * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
+ *
+ *
+ * @see filterByFeature()
+ *
+ * @param mixed $featureId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByFeatureId($featureId = null, $comparison = null)
+ {
+ if (is_array($featureId)) {
+ $useMinMax = false;
+ if (isset($featureId['min'])) {
+ $this->addUsingAlias(FeatureProdPeer::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureId['max'])) {
+ $this->addUsingAlias(FeatureProdPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdPeer::FEATURE_ID, $featureId, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_av_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureAvId(1234); // WHERE feature_av_id = 1234
+ * $query->filterByFeatureAvId(array(12, 34)); // WHERE feature_av_id IN (12, 34)
+ * $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id > 12
+ *
+ *
+ * @see filterByFeatureAv()
+ *
+ * @param mixed $featureAvId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAvId($featureAvId = null, $comparison = null)
+ {
+ if (is_array($featureAvId)) {
+ $useMinMax = false;
+ if (isset($featureAvId['min'])) {
+ $this->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAvId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureAvId['max'])) {
+ $this->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAvId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAvId, $comparison);
+ }
+
+ /**
+ * Filter the query on the default_utility column
+ *
+ * Example usage:
+ *
+ * $query->filterByDefaultUtility('fooValue'); // WHERE default_utility = 'fooValue'
+ * $query->filterByDefaultUtility('%fooValue%'); // WHERE default_utility LIKE '%fooValue%'
+ *
+ *
+ * @param string $defaultUtility The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByDefaultUtility($defaultUtility = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($defaultUtility)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $defaultUtility)) {
+ $defaultUtility = str_replace('*', '%', $defaultUtility);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdPeer::DEFAULT_UTILITY, $defaultUtility, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(FeatureProdPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FeatureProdPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeatureProdPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeatureProdPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ 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(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 filterByFeature($feature, $comparison = null)
+ {
+ if ($feature instanceof Feature) {
+ return $this
+ ->addUsingAlias(FeatureProdPeer::FEATURE_ID, $feature->getId(), $comparison);
+ } elseif ($feature instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureProdPeer::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 FeatureProdQuery 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 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 FeatureProdQuery 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(FeatureProdPeer::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureProdPeer::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 FeatureProdQuery 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
+ *
+ * @param FeatureProd $featureProd Object to remove from the list of results
+ *
+ * @return FeatureProdQuery The current query, for fluid interface
+ */
+ public function prune($featureProd = null)
+ {
+ if ($featureProd) {
+ $this->addUsingAlias(FeatureProdPeer::ID, $featureProd->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFeatureQuery.php b/core/lib/Thelia/Model/om/BaseFeatureQuery.php
new file mode 100644
index 000000000..8693b761e
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFeatureQuery.php
@@ -0,0 +1,759 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Feature|Feature[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeaturePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Feature A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `feature` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Feature();
+ $obj->hydrate($row);
+ FeaturePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Feature|Feature[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Feature[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeaturePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeaturePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FeaturePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(FeaturePeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(FeaturePeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeaturePeer::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(FeaturePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FeaturePeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeaturePeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related FeatureAv object
+ *
+ * @param FeatureAv|PropelObjectCollection $featureAv the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFeatureAv($featureAv, $comparison = null)
+ {
+ if ($featureAv instanceof FeatureAv) {
+ return $this
+ ->addUsingAlias(FeaturePeer::ID, $featureAv->getFeatureId(), $comparison);
+ } elseif ($featureAv instanceof PropelObjectCollection) {
+ return $this
+ ->useFeatureAvQuery()
+ ->filterByPrimaryKeys($featureAv->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function joinFeatureAv($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureAv');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureAv relation FeatureAv object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery');
+ }
+
+ /**
+ * Filter the query by a related FeatureCategory object
+ *
+ * @param FeatureCategory|PropelObjectCollection $featureCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFeatureCategory($featureCategory, $comparison = null)
+ {
+ if ($featureCategory instanceof FeatureCategory) {
+ return $this
+ ->addUsingAlias(FeaturePeer::ID, $featureCategory->getFeatureId(), $comparison);
+ } elseif ($featureCategory instanceof PropelObjectCollection) {
+ return $this
+ ->useFeatureCategoryQuery()
+ ->filterByPrimaryKeys($featureCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureCategory relation FeatureCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related FeatureDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFeatureDesc($featureDesc, $comparison = null)
+ {
+ if ($featureDesc instanceof FeatureDesc) {
+ return $this
+ ->addUsingAlias(FeaturePeer::ID, $featureDesc->getFeatureId(), $comparison);
+ } elseif ($featureDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useFeatureDescQuery()
+ ->filterByPrimaryKeys($featureDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureDesc() only accepts arguments of type FeatureDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function joinFeatureDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureDesc');
+
+ // 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, 'FeatureDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureDesc relation FeatureDesc 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\FeatureDescQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureDesc', '\Thelia\Model\FeatureDescQuery');
+ }
+
+ /**
+ * Filter the query by a related FeatureProd object
+ *
+ * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFeatureProd($featureProd, $comparison = null)
+ {
+ if ($featureProd instanceof FeatureProd) {
+ return $this
+ ->addUsingAlias(FeaturePeer::ID, $featureProd->getFeatureId(), $comparison);
+ } elseif ($featureProd instanceof PropelObjectCollection) {
+ return $this
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureProd relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureProd');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureProd');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureProd relation FeatureProd object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureProd($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Feature $feature Object to remove from the list of results
+ *
+ * @return FeatureQuery The current query, for fluid interface
+ */
+ public function prune($feature = null)
+ {
+ if ($feature) {
+ $this->addUsingAlias(FeaturePeer::ID, $feature->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFolder.php b/core/lib/Thelia/Model/om/BaseFolder.php
new file mode 100644
index 000000000..21df7c4de
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolder.php
@@ -0,0 +1,2784 @@
+id;
+ }
+
+ /**
+ * Get the [parent] column value.
+ *
+ * @return int
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Get the [link] column value.
+ *
+ * @return string
+ */
+ public function getLink()
+ {
+ return $this->link;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FolderPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setParent($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent !== $v) {
+ $this->parent = $v;
+ $this->modifiedColumns[] = FolderPeer::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Set the value of [link] column.
+ *
+ * @param string $v new value
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setLink($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->link !== $v) {
+ $this->link = $v;
+ $this->modifiedColumns[] = FolderPeer::LINK;
+ }
+
+
+ return $this;
+ } // setLink()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = FolderPeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = FolderPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = FolderPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = FolderPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->parent = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->link = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->visible = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = FolderPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Folder object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = FolderPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collContentFolders = null;
+
+ $this->collDocuments = null;
+
+ $this->collFolderDescs = null;
+
+ $this->collImages = null;
+
+ $this->collRewritings = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FolderQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FolderPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FolderPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FolderPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FolderPeer::PARENT)) {
+ $modifiedColumns[':p' . $index++] = '`PARENT`';
+ }
+ if ($this->isColumnModified(FolderPeer::LINK)) {
+ $modifiedColumns[':p' . $index++] = '`LINK`';
+ }
+ if ($this->isColumnModified(FolderPeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(FolderPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(FolderPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(FolderPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `folder` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`PARENT`':
+ $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
+ break;
+ case '`LINK`':
+ $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
+ break;
+ case '`VISIBLE`':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getParent();
+ break;
+ case 2:
+ return $this->getLink();
+ break;
+ case 3:
+ return $this->getVisible();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Folder'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Folder'][$this->getPrimaryKey()] = true;
+ $keys = FolderPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getParent(),
+ $keys[2] => $this->getLink(),
+ $keys[3] => $this->getVisible(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collContentFolders) {
+ $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFolderDescs) {
+ $result['FolderDescs'] = $this->collFolderDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setParent($value);
+ break;
+ case 2:
+ $this->setLink($value);
+ break;
+ case 3:
+ $this->setVisible($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = FolderPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(FolderPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FolderPeer::ID)) $criteria->add(FolderPeer::ID, $this->id);
+ if ($this->isColumnModified(FolderPeer::PARENT)) $criteria->add(FolderPeer::PARENT, $this->parent);
+ if ($this->isColumnModified(FolderPeer::LINK)) $criteria->add(FolderPeer::LINK, $this->link);
+ if ($this->isColumnModified(FolderPeer::VISIBLE)) $criteria->add(FolderPeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(FolderPeer::POSITION)) $criteria->add(FolderPeer::POSITION, $this->position);
+ if ($this->isColumnModified(FolderPeer::CREATED_AT)) $criteria->add(FolderPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FolderPeer::UPDATED_AT)) $criteria->add(FolderPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(FolderPeer::DATABASE_NAME);
+ $criteria->add(FolderPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Folder (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setParent($this->getParent());
+ $copyObj->setLink($this->getLink());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getContentFolders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentFolder($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDocuments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocument($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFolderDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFolderDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getImages() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImage($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Folder Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return FolderPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FolderPeer();
+ }
+
+ 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.
+ *
+ * @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 getContentFolders($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collContentFoldersPartial && !$this->isNew();
+ if (null === $this->collContentFolders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentFolders) {
+ // return empty collection
+ $this->initContentFolders();
+ } else {
+ $collContentFolders = ContentFolderQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collContentFoldersPartial && count($collContentFolders)) {
+ $this->initContentFolders(false);
+
+ foreach($collContentFolders as $obj) {
+ if (false == $this->collContentFolders->contains($obj)) {
+ $this->collContentFolders->append($obj);
+ }
+ }
+
+ $this->collContentFoldersPartial = true;
+ }
+
+ return $collContentFolders;
+ }
+
+ if($partial && $this->collContentFolders) {
+ foreach($this->collContentFolders as $obj) {
+ if($obj->isNew()) {
+ $collContentFolders[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentFolders = $collContentFolders;
+ $this->collContentFoldersPartial = false;
+ }
+ }
+
+ return $this->collContentFolders;
+ }
+
+ /**
+ * Sets a collection of ContentFolder objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $contentFolders A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null)
+ {
+ $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders);
+
+ foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) {
+ $contentFolderRemoved->setFolder(null);
+ }
+
+ $this->collContentFolders = null;
+ foreach ($contentFolders as $contentFolder) {
+ $this->addContentFolder($contentFolder);
+ }
+
+ $this->collContentFolders = $contentFolders;
+ $this->collContentFoldersPartial = false;
+ }
+
+ /**
+ * Returns the number of related ContentFolder objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ContentFolder objects.
+ * @throws PropelException
+ */
+ public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collContentFoldersPartial && !$this->isNew();
+ if (null === $this->collContentFolders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentFolders) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getContentFolders());
+ }
+ $query = ContentFolderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collContentFolders);
+ }
+ }
+
+ /**
+ * Method called to associate a ContentFolder object to this object
+ * through the ContentFolder foreign key attribute.
+ *
+ * @param ContentFolder $l ContentFolder
+ * @return Folder The current object (for fluent API support)
+ */
+ public function addContentFolder(ContentFolder $l)
+ {
+ if ($this->collContentFolders === null) {
+ $this->initContentFolders();
+ $this->collContentFoldersPartial = true;
+ }
+ if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddContentFolder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentFolder $contentFolder The contentFolder object to add.
+ */
+ protected function doAddContentFolder($contentFolder)
+ {
+ $this->collContentFolders[]= $contentFolder;
+ $contentFolder->setFolder($this);
+ }
+
+ /**
+ * @param ContentFolder $contentFolder The contentFolder object to remove.
+ */
+ public function removeContentFolder($contentFolder)
+ {
+ if ($this->getContentFolders()->contains($contentFolder)) {
+ $this->collContentFolders->remove($this->collContentFolders->search($contentFolder));
+ if (null === $this->contentFoldersScheduledForDeletion) {
+ $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders;
+ $this->contentFoldersScheduledForDeletion->clear();
+ }
+ $this->contentFoldersScheduledForDeletion[]= $contentFolder;
+ $contentFolder->setFolder(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related ContentFolders from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects
+ */
+ public function getContentFoldersJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = ContentFolderQuery::create(null, $criteria);
+ $query->joinWith('Content', $join_behavior);
+
+ return $this->getContentFolders($query, $con);
+ }
+
+ /**
+ * Clears out the collDocuments collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addDocuments()
+ */
+ public function clearDocuments()
+ {
+ $this->collDocuments = null; // important to set this to null since that means it is uninitialized
+ $this->collDocumentsPartial = null;
+ }
+
+ /**
+ * reset is the collDocuments collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialDocuments($v = true)
+ {
+ $this->collDocumentsPartial = $v;
+ }
+
+ /**
+ * Initializes the collDocuments collection.
+ *
+ * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initDocuments($overrideExisting = true)
+ {
+ if (null !== $this->collDocuments && !$overrideExisting) {
+ return;
+ }
+ $this->collDocuments = new PropelObjectCollection();
+ $this->collDocuments->setModel('Document');
+ }
+
+ /**
+ * Gets an array of Document objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this Folder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|Document[] List of Document objects
+ * @throws PropelException
+ */
+ public function getDocuments($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ // return empty collection
+ $this->initDocuments();
+ } else {
+ $collDocuments = DocumentQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentsPartial && count($collDocuments)) {
+ $this->initDocuments(false);
+
+ foreach($collDocuments as $obj) {
+ if (false == $this->collDocuments->contains($obj)) {
+ $this->collDocuments->append($obj);
+ }
+ }
+
+ $this->collDocumentsPartial = true;
+ }
+
+ return $collDocuments;
+ }
+
+ if($partial && $this->collDocuments) {
+ foreach($this->collDocuments as $obj) {
+ if($obj->isNew()) {
+ $collDocuments[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocuments = $collDocuments;
+ $this->collDocumentsPartial = false;
+ }
+ }
+
+ return $this->collDocuments;
+ }
+
+ /**
+ * Sets a collection of Document objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $documents A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setDocuments(PropelCollection $documents, PropelPDO $con = null)
+ {
+ $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents);
+
+ foreach ($this->documentsScheduledForDeletion as $documentRemoved) {
+ $documentRemoved->setFolder(null);
+ }
+
+ $this->collDocuments = null;
+ foreach ($documents as $document) {
+ $this->addDocument($document);
+ }
+
+ $this->collDocuments = $documents;
+ $this->collDocumentsPartial = false;
+ }
+
+ /**
+ * Returns the number of related Document objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related Document objects.
+ * @throws PropelException
+ */
+ public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getDocuments());
+ }
+ $query = DocumentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collDocuments);
+ }
+ }
+
+ /**
+ * Method called to associate a Document object to this object
+ * through the Document foreign key attribute.
+ *
+ * @param Document $l Document
+ * @return Folder The current object (for fluent API support)
+ */
+ public function addDocument(Document $l)
+ {
+ if ($this->collDocuments === null) {
+ $this->initDocuments();
+ $this->collDocumentsPartial = true;
+ }
+ if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddDocument($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Document $document The document object to add.
+ */
+ protected function doAddDocument($document)
+ {
+ $this->collDocuments[]= $document;
+ $document->setFolder($this);
+ }
+
+ /**
+ * @param Document $document The document object to remove.
+ */
+ public function removeDocument($document)
+ {
+ if ($this->getDocuments()->contains($document)) {
+ $this->collDocuments->remove($this->collDocuments->search($document));
+ if (null === $this->documentsScheduledForDeletion) {
+ $this->documentsScheduledForDeletion = clone $this->collDocuments;
+ $this->documentsScheduledForDeletion->clear();
+ }
+ $this->documentsScheduledForDeletion[]= $document;
+ $document->setFolder(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Product', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Category', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Documents from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|Document[] List of Document objects
+ */
+ public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = DocumentQuery::create(null, $criteria);
+ $query->joinWith('Content', $join_behavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+ /**
+ * Clears out the 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 getFolderDescs($criteria = null, PropelPDO $con = 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 {
+ return count($this->collFolderDescs);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param FolderDesc $folderDesc The folderDesc object to add.
+ */
+ protected function doAddFolderDesc($folderDesc)
+ {
+ $this->collFolderDescs[]= $folderDesc;
+ $folderDesc->setFolder($this);
+ }
+
+ /**
+ * @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
+ *
+ * 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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param Image $image The image object to add.
+ */
+ protected function doAddImage($image)
+ {
+ $this->collImages[]= $image;
+ $image->setFolder($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->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.
+ *
+ * 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 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)
+ ->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 {
+ 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 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);
+ }
+
+ /**
+ * @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->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 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);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->parent = null;
+ $this->link = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ 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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FolderPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFolderDesc.php b/core/lib/Thelia/Model/om/BaseFolderDesc.php
new file mode 100644
index 000000000..39392a103
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolderDesc.php
@@ -0,0 +1,1375 @@
+id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+ return $this->folder_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->postscriptum;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FolderDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = FolderDescPeer::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = FolderDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = FolderDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = FolderDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = FolderDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = FolderDescPeer::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = FolderDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return FolderDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = FolderDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->folder_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->postscriptum = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = FolderDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating FolderDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = FolderDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFolder = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FolderDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FolderDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FolderDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FolderDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FolderDescPeer::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FOLDER_ID`';
+ }
+ if ($this->isColumnModified(FolderDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(FolderDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(FolderDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(FolderDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(FolderDescPeer::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`';
+ }
+ if ($this->isColumnModified(FolderDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(FolderDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `folder_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`FOLDER_ID`':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`POSTSCRIPTUM`':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FolderDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getFolderId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getPostscriptum();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FolderDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FolderDesc'][$this->getPrimaryKey()] = true;
+ $keys = FolderDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFolderId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getPostscriptum(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = FolderDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setFolderId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setPostscriptum($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = FolderDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setPostscriptum($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(FolderDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FolderDescPeer::ID)) $criteria->add(FolderDescPeer::ID, $this->id);
+ if ($this->isColumnModified(FolderDescPeer::FOLDER_ID)) $criteria->add(FolderDescPeer::FOLDER_ID, $this->folder_id);
+ if ($this->isColumnModified(FolderDescPeer::LANG)) $criteria->add(FolderDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(FolderDescPeer::TITLE)) $criteria->add(FolderDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(FolderDescPeer::DESCRIPTION)) $criteria->add(FolderDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(FolderDescPeer::CHAPO)) $criteria->add(FolderDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(FolderDescPeer::POSTSCRIPTUM)) $criteria->add(FolderDescPeer::POSTSCRIPTUM, $this->postscriptum);
+ if ($this->isColumnModified(FolderDescPeer::CREATED_AT)) $criteria->add(FolderDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FolderDescPeer::UPDATED_AT)) $criteria->add(FolderDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(FolderDescPeer::DATABASE_NAME);
+ $criteria->add(FolderDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of FolderDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFolderId($this->getFolderId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return FolderDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return FolderDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FolderDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Folder object.
+ *
+ * @param Folder $v
+ * @return FolderDesc 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->folder_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aFolder = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FolderDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFolderDescPeer.php b/core/lib/Thelia/Model/om/BaseFolderDescPeer.php
new file mode 100644
index 000000000..92d614047
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolderDescPeer.php
@@ -0,0 +1,1042 @@
+ array ('Id', 'FolderId', 'Lang', 'Title', 'Description', 'Chapo', 'Postscriptum', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'folderId', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (FolderDescPeer::ID, FolderDescPeer::FOLDER_ID, FolderDescPeer::LANG, FolderDescPeer::TITLE, FolderDescPeer::DESCRIPTION, FolderDescPeer::CHAPO, FolderDescPeer::POSTSCRIPTUM, FolderDescPeer::CREATED_AT, FolderDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FOLDER_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'folder_id', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. FolderDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FolderId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Postscriptum' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'folderId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ BasePeer::TYPE_COLNAME => array (FolderDescPeer::ID => 0, FolderDescPeer::FOLDER_ID => 1, FolderDescPeer::LANG => 2, FolderDescPeer::TITLE => 3, FolderDescPeer::DESCRIPTION => 4, FolderDescPeer::CHAPO => 5, FolderDescPeer::POSTSCRIPTUM => 6, FolderDescPeer::CREATED_AT => 7, FolderDescPeer::UPDATED_AT => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FOLDER_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'POSTSCRIPTUM' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'folder_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = FolderDescPeer::getFieldNames($toType);
+ $key = isset(FolderDescPeer::$fieldKeys[$fromType][$name]) ? FolderDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FolderDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, FolderDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return FolderDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. FolderDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FolderDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FolderDescPeer::ID);
+ $criteria->addSelectColumn(FolderDescPeer::FOLDER_ID);
+ $criteria->addSelectColumn(FolderDescPeer::LANG);
+ $criteria->addSelectColumn(FolderDescPeer::TITLE);
+ $criteria->addSelectColumn(FolderDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(FolderDescPeer::CHAPO);
+ $criteria->addSelectColumn(FolderDescPeer::POSTSCRIPTUM);
+ $criteria->addSelectColumn(FolderDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(FolderDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return FolderDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = FolderDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return FolderDescPeer::populateObjects(FolderDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FolderDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param FolderDesc $obj A FolderDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ FolderDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A FolderDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof FolderDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FolderDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FolderDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return FolderDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(FolderDescPeer::$instances[$key])) {
+ return FolderDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FolderDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to folder_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = FolderDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FolderDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FolderDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FolderDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FolderDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FolderDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FolderDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + FolderDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FolderDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FolderDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(FolderDescPeer::DATABASE_NAME)->getTable(FolderDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFolderDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFolderDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FolderDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FolderDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FolderDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or FolderDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from FolderDesc object
+ }
+
+ if ($criteria->containsKey(FolderDescPeer::ID) && $criteria->keyContainsValue(FolderDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FolderDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a FolderDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or FolderDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FolderDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FolderDescPeer::ID);
+ $value = $criteria->remove(FolderDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(FolderDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FolderDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is FolderDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the folder_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ FolderDescPeer::clearInstancePool();
+ FolderDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FolderDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FolderDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(FolderDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ FolderDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given FolderDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param FolderDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(FolderDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FolderDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(FolderDescPeer::DATABASE_NAME, FolderDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return FolderDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = FolderDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(FolderDescPeer::DATABASE_NAME);
+ $criteria->add(FolderDescPeer::ID, $pk);
+
+ $v = FolderDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return FolderDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(FolderDescPeer::DATABASE_NAME);
+ $criteria->add(FolderDescPeer::ID, $pks, Criteria::IN);
+ $objs = FolderDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseFolderDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFolderDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFolderDescQuery.php b/core/lib/Thelia/Model/om/BaseFolderDescQuery.php
new file mode 100644
index 000000000..761634ea3
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolderDescQuery.php
@@ -0,0 +1,646 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return FolderDesc|FolderDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FolderDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(FolderDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FolderDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `FOLDER_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM`, `CREATED_AT`, `UPDATED_AT` FROM `folder_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new FolderDesc();
+ $obj->hydrate($row);
+ FolderDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return FolderDesc|FolderDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|FolderDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FolderDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FolderDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId)) {
+ $useMinMax = false;
+ if (isset($folderId['min'])) {
+ $this->addUsingAlias(FolderDescPeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($folderId['max'])) {
+ $this->addUsingAlias(FolderDescPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FolderDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FolderDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FolderDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FolderDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 FolderDescQuery 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(FolderDescPeer::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FolderDescPeer::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 FolderDescQuery 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');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param FolderDesc $folderDesc Object to remove from the list of results
+ *
+ * @return FolderDescQuery The current query, for fluid interface
+ */
+ public function prune($folderDesc = null)
+ {
+ if ($folderDesc) {
+ $this->addUsingAlias(FolderDescPeer::ID, $folderDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFolderPeer.php b/core/lib/Thelia/Model/om/BaseFolderPeer.php
new file mode 100644
index 000000000..6a45fb85b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolderPeer.php
@@ -0,0 +1,813 @@
+ array ('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (FolderPeer::ID, FolderPeer::PARENT, FolderPeer::LINK, FolderPeer::VISIBLE, FolderPeer::POSITION, FolderPeer::CREATED_AT, FolderPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. FolderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (FolderPeer::ID => 0, FolderPeer::PARENT => 1, FolderPeer::LINK => 2, FolderPeer::VISIBLE => 3, FolderPeer::POSITION => 4, FolderPeer::CREATED_AT => 5, FolderPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = FolderPeer::getFieldNames($toType);
+ $key = isset(FolderPeer::$fieldKeys[$fromType][$name]) ? FolderPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FolderPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, FolderPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return FolderPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. FolderPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FolderPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FolderPeer::ID);
+ $criteria->addSelectColumn(FolderPeer::PARENT);
+ $criteria->addSelectColumn(FolderPeer::LINK);
+ $criteria->addSelectColumn(FolderPeer::VISIBLE);
+ $criteria->addSelectColumn(FolderPeer::POSITION);
+ $criteria->addSelectColumn(FolderPeer::CREATED_AT);
+ $criteria->addSelectColumn(FolderPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.LINK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(FolderPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Folder
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = FolderPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return FolderPeer::populateObjects(FolderPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FolderPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Folder $obj A Folder object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ FolderPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Folder object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Folder) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Folder object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FolderPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Folder Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(FolderPeer::$instances[$key])) {
+ return FolderPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FolderPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to folder
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = FolderPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FolderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FolderPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FolderPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Folder object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FolderPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + FolderPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FolderPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FolderPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(FolderPeer::DATABASE_NAME)->getTable(FolderPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFolderPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFolderPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FolderTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FolderPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Folder or Criteria object.
+ *
+ * @param mixed $values Criteria or Folder object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Folder object
+ }
+
+ if ($criteria->containsKey(FolderPeer::ID) && $criteria->keyContainsValue(FolderPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FolderPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Folder or Criteria object.
+ *
+ * @param mixed $values Criteria or Folder object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FolderPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FolderPeer::ID);
+ $value = $criteria->remove(FolderPeer::ID);
+ if ($value) {
+ $selectCriteria->add(FolderPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FolderPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Folder object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FolderPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the folder table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(FolderPeer::TABLE_NAME, $con, FolderPeer::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
+ // instances get re-added by the select statement contained therein).
+ FolderPeer::clearInstancePool();
+ FolderPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Folder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Folder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ FolderPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Folder) { // it's a model object
+ // invalidate the cache for this single object
+ FolderPeer::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(FolderPeer::DATABASE_NAME);
+ $criteria->add(FolderPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ FolderPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ FolderPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Folder object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Folder $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(FolderPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FolderPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(FolderPeer::DATABASE_NAME, FolderPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Folder
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = FolderPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(FolderPeer::DATABASE_NAME);
+ $criteria->add(FolderPeer::ID, $pk);
+
+ $v = FolderPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Folder[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(FolderPeer::DATABASE_NAME);
+ $criteria->add(FolderPeer::ID, $pks, Criteria::IN);
+ $objs = FolderPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseFolderPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFolderPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFolderQuery.php b/core/lib/Thelia/Model/om/BaseFolderQuery.php
new file mode 100644
index 000000000..d4e88949a
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolderQuery.php
@@ -0,0 +1,916 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Folder|Folder[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FolderPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Folder A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `folder` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Folder();
+ $obj->hydrate($row);
+ FolderPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Folder|Folder[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Folder[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FolderPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FolderPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FolderPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent column
+ *
+ * Example usage:
+ *
+ * $query->filterByParent(1234); // WHERE parent = 1234
+ * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
+ * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
+ *
+ *
+ * @param mixed $parent The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterByParent($parent = null, $comparison = null)
+ {
+ if (is_array($parent)) {
+ $useMinMax = false;
+ if (isset($parent['min'])) {
+ $this->addUsingAlias(FolderPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(FolderPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::PARENT, $parent, $comparison);
+ }
+
+ /**
+ * Filter the query on the link column
+ *
+ * Example usage:
+ *
+ * $query->filterByLink('fooValue'); // WHERE link = 'fooValue'
+ * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%'
+ *
+ *
+ * @param string $link The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterByLink($link = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($link)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $link)) {
+ $link = str_replace('*', '%', $link);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::LINK, $link, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(FolderPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(FolderPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(FolderPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FolderPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FolderPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FolderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related ContentFolder object
+ *
+ * @param ContentFolder|PropelObjectCollection $contentFolder the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContentFolder($contentFolder, $comparison = null)
+ {
+ if ($contentFolder instanceof ContentFolder) {
+ return $this
+ ->addUsingAlias(FolderPeer::ID, $contentFolder->getFolderId(), $comparison);
+ } elseif ($contentFolder instanceof PropelObjectCollection) {
+ return $this
+ ->useContentFolderQuery()
+ ->filterByPrimaryKeys($contentFolder->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentFolder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentFolder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentFolder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentFolder relation ContentFolder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query
+ */
+ public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContentFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery');
+ }
+
+ /**
+ * Filter the query by a related Document object
+ *
+ * @param Document|PropelObjectCollection $document the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof Document) {
+ return $this
+ ->addUsingAlias(FolderPeer::ID, $document->getFolderId(), $comparison);
+ } elseif ($document instanceof PropelObjectCollection) {
+ return $this
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Filter the query by a related FolderDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFolderDesc($folderDesc, $comparison = null)
+ {
+ if ($folderDesc instanceof FolderDesc) {
+ return $this
+ ->addUsingAlias(FolderPeer::ID, $folderDesc->getFolderId(), $comparison);
+ } elseif ($folderDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useFolderDescQuery()
+ ->filterByPrimaryKeys($folderDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFolderDesc() only accepts arguments of type FolderDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FolderDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function joinFolderDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FolderDesc');
+
+ // 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, 'FolderDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FolderDesc relation FolderDesc 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\FolderDescQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFolderDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FolderDesc', '\Thelia\Model\FolderDescQuery');
+ }
+
+ /**
+ * Filter the query by a related Image object
+ *
+ * @param Image|PropelObjectCollection $image the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof Image) {
+ return $this
+ ->addUsingAlias(FolderPeer::ID, $image->getFolderId(), $comparison);
+ } elseif ($image instanceof PropelObjectCollection) {
+ return $this
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Filter the query by a related Rewriting object
+ *
+ * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByRewriting($rewriting, $comparison = null)
+ {
+ if ($rewriting instanceof Rewriting) {
+ return $this
+ ->addUsingAlias(FolderPeer::ID, $rewriting->getFolderId(), $comparison);
+ } elseif ($rewriting instanceof PropelObjectCollection) {
+ return $this
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Rewriting relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Rewriting');
+
+ // 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, 'Rewriting');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Rewriting relation Rewriting 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\RewritingQuery A secondary query class using the current class as primary query
+ */
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinRewriting($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Folder $folder Object to remove from the list of results
+ *
+ * @return FolderQuery The current query, for fluid interface
+ */
+ public function prune($folder = null)
+ {
+ if ($folder) {
+ $this->addUsingAlias(FolderPeer::ID, $folder->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseGroup.php b/core/lib/Thelia/Model/om/BaseGroup.php
new file mode 100644
index 000000000..48895894a
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroup.php
@@ -0,0 +1,2173 @@
+id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Group The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = GroupPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return Group The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = GroupPeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Group The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = GroupPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Group The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = GroupPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = GroupPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Group object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = GroupPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAdminGroups = null;
+
+ $this->collGroupDescs = null;
+
+ $this->collGroupModules = null;
+
+ $this->collGroupResources = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = GroupQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ GroupPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = GroupPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(GroupPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(GroupPeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(GroupPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(GroupPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `group` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = GroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Group'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Group'][$this->getPrimaryKey()] = true;
+ $keys = GroupPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collAdminGroups) {
+ $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collGroupDescs) {
+ $result['GroupDescs'] = $this->collGroupDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collGroupModules) {
+ $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collGroupResources) {
+ $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = GroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = GroupPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(GroupPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(GroupPeer::ID)) $criteria->add(GroupPeer::ID, $this->id);
+ if ($this->isColumnModified(GroupPeer::CODE)) $criteria->add(GroupPeer::CODE, $this->code);
+ if ($this->isColumnModified(GroupPeer::CREATED_AT)) $criteria->add(GroupPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(GroupPeer::UPDATED_AT)) $criteria->add(GroupPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(GroupPeer::DATABASE_NAME);
+ $criteria->add(GroupPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Group (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getAdminGroups() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAdminGroup($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getGroupDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getGroupModules() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupModule($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getGroupResources() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupResource($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Group Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return GroupPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new GroupPeer();
+ }
+
+ 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.
+ *
+ * @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 getAdminGroups($criteria = null, PropelPDO $con = 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 {
+ return count($this->collAdminGroups);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param AdminGroup $adminGroup The adminGroup object to add.
+ */
+ protected function doAddAdminGroup($adminGroup)
+ {
+ $this->collAdminGroups[]= $adminGroup;
+ $adminGroup->setGroup($this);
+ }
+
+ /**
+ * @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.
+ *
+ * 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 getGroupDescs($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collGroupDescsPartial && !$this->isNew();
+ if (null === $this->collGroupDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupDescs) {
+ // return empty collection
+ $this->initGroupDescs();
+ } else {
+ $collGroupDescs = GroupDescQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collGroupDescsPartial && count($collGroupDescs)) {
+ $this->initGroupDescs(false);
+
+ foreach($collGroupDescs as $obj) {
+ if (false == $this->collGroupDescs->contains($obj)) {
+ $this->collGroupDescs->append($obj);
+ }
+ }
+
+ $this->collGroupDescsPartial = true;
+ }
+
+ return $collGroupDescs;
+ }
+
+ if($partial && $this->collGroupDescs) {
+ foreach($this->collGroupDescs as $obj) {
+ if($obj->isNew()) {
+ $collGroupDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupDescs = $collGroupDescs;
+ $this->collGroupDescsPartial = false;
+ }
+ }
+
+ return $this->collGroupDescs;
+ }
+
+ /**
+ * Sets a collection of GroupDesc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $groupDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setGroupDescs(PropelCollection $groupDescs, PropelPDO $con = null)
+ {
+ $this->groupDescsScheduledForDeletion = $this->getGroupDescs(new Criteria(), $con)->diff($groupDescs);
+
+ foreach ($this->groupDescsScheduledForDeletion as $groupDescRemoved) {
+ $groupDescRemoved->setGroup(null);
+ }
+
+ $this->collGroupDescs = null;
+ foreach ($groupDescs as $groupDesc) {
+ $this->addGroupDesc($groupDesc);
+ }
+
+ $this->collGroupDescs = $groupDescs;
+ $this->collGroupDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related GroupDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related GroupDesc objects.
+ * @throws PropelException
+ */
+ public function countGroupDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collGroupDescsPartial && !$this->isNew();
+ if (null === $this->collGroupDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getGroupDescs());
+ }
+ $query = GroupDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collGroupDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a GroupDesc object to this object
+ * through the GroupDesc foreign key attribute.
+ *
+ * @param GroupDesc $l GroupDesc
+ * @return Group The current object (for fluent API support)
+ */
+ public function addGroupDesc(GroupDesc $l)
+ {
+ if ($this->collGroupDescs === null) {
+ $this->initGroupDescs();
+ $this->collGroupDescsPartial = true;
+ }
+ if (!$this->collGroupDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupDesc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param GroupDesc $groupDesc The groupDesc object to add.
+ */
+ protected function doAddGroupDesc($groupDesc)
+ {
+ $this->collGroupDescs[]= $groupDesc;
+ $groupDesc->setGroup($this);
+ }
+
+ /**
+ * @param GroupDesc $groupDesc The groupDesc object to remove.
+ */
+ public function removeGroupDesc($groupDesc)
+ {
+ if ($this->getGroupDescs()->contains($groupDesc)) {
+ $this->collGroupDescs->remove($this->collGroupDescs->search($groupDesc));
+ if (null === $this->groupDescsScheduledForDeletion) {
+ $this->groupDescsScheduledForDeletion = clone $this->collGroupDescs;
+ $this->groupDescsScheduledForDeletion->clear();
+ }
+ $this->groupDescsScheduledForDeletion[]= $groupDesc;
+ $groupDesc->setGroup(null);
+ }
+ }
+
+ /**
+ * 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 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 getGroupModules($criteria = null, PropelPDO $con = 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 {
+ return count($this->collGroupModules);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param GroupModule $groupModule The groupModule object to add.
+ */
+ protected function doAddGroupModule($groupModule)
+ {
+ $this->collGroupModules[]= $groupModule;
+ $groupModule->setGroup($this);
+ }
+
+ /**
+ * @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.
+ *
+ * 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 getGroupResources($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collGroupResourcesPartial && !$this->isNew();
+ if (null === $this->collGroupResources || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupResources) {
+ // return empty collection
+ $this->initGroupResources();
+ } else {
+ $collGroupResources = GroupResourceQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) {
+ $this->initGroupResources(false);
+
+ foreach($collGroupResources as $obj) {
+ if (false == $this->collGroupResources->contains($obj)) {
+ $this->collGroupResources->append($obj);
+ }
+ }
+
+ $this->collGroupResourcesPartial = true;
+ }
+
+ return $collGroupResources;
+ }
+
+ if($partial && $this->collGroupResources) {
+ foreach($this->collGroupResources as $obj) {
+ if($obj->isNew()) {
+ $collGroupResources[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupResources = $collGroupResources;
+ $this->collGroupResourcesPartial = false;
+ }
+ }
+
+ return $this->collGroupResources;
+ }
+
+ /**
+ * Sets a collection of GroupResource objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $groupResources A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null)
+ {
+ $this->groupResourcesScheduledForDeletion = $this->getGroupResources(new Criteria(), $con)->diff($groupResources);
+
+ foreach ($this->groupResourcesScheduledForDeletion as $groupResourceRemoved) {
+ $groupResourceRemoved->setGroup(null);
+ }
+
+ $this->collGroupResources = null;
+ foreach ($groupResources as $groupResource) {
+ $this->addGroupResource($groupResource);
+ }
+
+ $this->collGroupResources = $groupResources;
+ $this->collGroupResourcesPartial = false;
+ }
+
+ /**
+ * Returns the number of related GroupResource objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related GroupResource objects.
+ * @throws PropelException
+ */
+ public function countGroupResources(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collGroupResourcesPartial && !$this->isNew();
+ if (null === $this->collGroupResources || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupResources) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getGroupResources());
+ }
+ $query = GroupResourceQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collGroupResources);
+ }
+ }
+
+ /**
+ * Method called to associate a GroupResource object to this object
+ * through the GroupResource foreign key attribute.
+ *
+ * @param GroupResource $l GroupResource
+ * @return Group The current object (for fluent API support)
+ */
+ public function addGroupResource(GroupResource $l)
+ {
+ if ($this->collGroupResources === null) {
+ $this->initGroupResources();
+ $this->collGroupResourcesPartial = true;
+ }
+ if (!$this->collGroupResources->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupResource($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param GroupResource $groupResource The groupResource object to add.
+ */
+ protected function doAddGroupResource($groupResource)
+ {
+ $this->collGroupResources[]= $groupResource;
+ $groupResource->setGroup($this);
+ }
+
+ /**
+ * @param GroupResource $groupResource The groupResource object to remove.
+ */
+ public function removeGroupResource($groupResource)
+ {
+ if ($this->getGroupResources()->contains($groupResource)) {
+ $this->collGroupResources->remove($this->collGroupResources->search($groupResource));
+ if (null === $this->groupResourcesScheduledForDeletion) {
+ $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources;
+ $this->groupResourcesScheduledForDeletion->clear();
+ }
+ $this->groupResourcesScheduledForDeletion[]= $groupResource;
+ $groupResource->setGroup(null);
+ }
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Group is new, it will return
+ * an empty collection; or if this Group has previously
+ * been saved, it will retrieve related GroupResources from storage.
+ *
+ * This method is protected by default in order to keep the public
+ * api reasonable. You can provide public methods for those you
+ * actually need in Group.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return PropelObjectCollection|GroupResource[] List of GroupResource objects
+ */
+ public function getGroupResourcesJoinResource($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $query = GroupResourceQuery::create(null, $criteria);
+ $query->joinWith('Resource', $join_behavior);
+
+ return $this->getGroupResources($query, $con);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ 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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(GroupPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseGroupDesc.php b/core/lib/Thelia/Model/om/BaseGroupDesc.php
new file mode 100644
index 000000000..70c7ebc38
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupDesc.php
@@ -0,0 +1,1309 @@
+id;
+ }
+
+ /**
+ * Get the [group_id] column value.
+ *
+ * @return int
+ */
+ public function getGroupId()
+ {
+ return $this->group_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return GroupDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = GroupDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [group_id] column.
+ *
+ * @param int $v new value
+ * @return GroupDesc The current object (for fluent API support)
+ */
+ public function setGroupId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->group_id !== $v) {
+ $this->group_id = $v;
+ $this->modifiedColumns[] = GroupDescPeer::GROUP_ID;
+ }
+
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
+
+ return $this;
+ } // setGroupId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return GroupDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = GroupDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return GroupDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = GroupDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return GroupDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = GroupDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return GroupDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = GroupDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return GroupDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = GroupDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return GroupDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = GroupDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->group_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = GroupDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating GroupDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = GroupDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aGroup = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = GroupDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ GroupDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(GroupDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(GroupDescPeer::GROUP_ID)) {
+ $modifiedColumns[':p' . $index++] = '`GROUP_ID`';
+ }
+ if ($this->isColumnModified(GroupDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(GroupDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(GroupDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(GroupDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(GroupDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(GroupDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `group_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`GROUP_ID`':
+ $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = GroupDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getGroupId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['GroupDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['GroupDesc'][$this->getPrimaryKey()] = true;
+ $keys = GroupDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getGroupId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = GroupDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setGroupId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = GroupDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(GroupDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(GroupDescPeer::ID)) $criteria->add(GroupDescPeer::ID, $this->id);
+ if ($this->isColumnModified(GroupDescPeer::GROUP_ID)) $criteria->add(GroupDescPeer::GROUP_ID, $this->group_id);
+ if ($this->isColumnModified(GroupDescPeer::LANG)) $criteria->add(GroupDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(GroupDescPeer::TITLE)) $criteria->add(GroupDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(GroupDescPeer::DESCRIPTION)) $criteria->add(GroupDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(GroupDescPeer::CHAPO)) $criteria->add(GroupDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(GroupDescPeer::CREATED_AT)) $criteria->add(GroupDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(GroupDescPeer::UPDATED_AT)) $criteria->add(GroupDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(GroupDescPeer::DATABASE_NAME);
+ $criteria->add(GroupDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of GroupDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setGroupId($this->getGroupId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return GroupDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return GroupDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new GroupDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Group object.
+ *
+ * @param Group $v
+ * @return GroupDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setGroup(Group $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->group_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aGroup = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(GroupDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseGroupDescPeer.php b/core/lib/Thelia/Model/om/BaseGroupDescPeer.php
new file mode 100644
index 000000000..968d5789c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupDescPeer.php
@@ -0,0 +1,1033 @@
+ array ('Id', 'GroupId', 'Lang', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'groupId', 'lang', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (GroupDescPeer::ID, GroupDescPeer::GROUP_ID, GroupDescPeer::LANG, GroupDescPeer::TITLE, GroupDescPeer::DESCRIPTION, GroupDescPeer::CHAPO, GroupDescPeer::CREATED_AT, GroupDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GROUP_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'group_id', 'lang', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. GroupDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'GroupId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'groupId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (GroupDescPeer::ID => 0, GroupDescPeer::GROUP_ID => 1, GroupDescPeer::LANG => 2, GroupDescPeer::TITLE => 3, GroupDescPeer::DESCRIPTION => 4, GroupDescPeer::CHAPO => 5, GroupDescPeer::CREATED_AT => 6, GroupDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GROUP_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'group_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = GroupDescPeer::getFieldNames($toType);
+ $key = isset(GroupDescPeer::$fieldKeys[$fromType][$name]) ? GroupDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(GroupDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, GroupDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return GroupDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. GroupDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(GroupDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(GroupDescPeer::ID);
+ $criteria->addSelectColumn(GroupDescPeer::GROUP_ID);
+ $criteria->addSelectColumn(GroupDescPeer::LANG);
+ $criteria->addSelectColumn(GroupDescPeer::TITLE);
+ $criteria->addSelectColumn(GroupDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(GroupDescPeer::CHAPO);
+ $criteria->addSelectColumn(GroupDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(GroupDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.GROUP_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return GroupDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = GroupDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return GroupDescPeer::populateObjects(GroupDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ GroupDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param GroupDesc $obj A GroupDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ GroupDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A GroupDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof GroupDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or GroupDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(GroupDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return GroupDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(GroupDescPeer::$instances[$key])) {
+ return GroupDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ GroupDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to group_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = GroupDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = GroupDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = GroupDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ GroupDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (GroupDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = GroupDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = GroupDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + GroupDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = GroupDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ GroupDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(GroupDescPeer::DATABASE_NAME)->getTable(GroupDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseGroupDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseGroupDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new GroupDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return GroupDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a GroupDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or GroupDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from GroupDesc object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a GroupDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or GroupDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(GroupDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(GroupDescPeer::ID);
+ $value = $criteria->remove(GroupDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(GroupDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(GroupDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is GroupDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the group_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ GroupDescPeer::clearInstancePool();
+ GroupDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a GroupDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or GroupDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(GroupDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ GroupDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given GroupDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param GroupDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(GroupDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(GroupDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(GroupDescPeer::DATABASE_NAME, GroupDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return GroupDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = GroupDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(GroupDescPeer::DATABASE_NAME);
+ $criteria->add(GroupDescPeer::ID, $pk);
+
+ $v = GroupDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return GroupDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(GroupDescPeer::DATABASE_NAME);
+ $criteria->add(GroupDescPeer::ID, $pks, Criteria::IN);
+ $objs = GroupDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseGroupDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseGroupDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseGroupDescQuery.php b/core/lib/Thelia/Model/om/BaseGroupDescQuery.php
new file mode 100644
index 000000000..7976f5572
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupDescQuery.php
@@ -0,0 +1,613 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return GroupDesc|GroupDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = GroupDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(GroupDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return GroupDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `GROUP_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `group_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new GroupDesc();
+ $obj->hydrate($row);
+ GroupDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return GroupDesc|GroupDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|GroupDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(GroupDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(GroupDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(GroupDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the group_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByGroupId(1234); // WHERE group_id = 1234
+ * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34)
+ * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
+ *
+ *
+ * @see filterByGroup()
+ *
+ * @param mixed $groupId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByGroupId($groupId = null, $comparison = null)
+ {
+ if (is_array($groupId)) {
+ $useMinMax = false;
+ if (isset($groupId['min'])) {
+ $this->addUsingAlias(GroupDescPeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($groupId['max'])) {
+ $this->addUsingAlias(GroupDescPeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupDescPeer::GROUP_ID, $groupId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(GroupDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(GroupDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(GroupDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(GroupDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Group object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroup($group, $comparison = null)
+ {
+ if ($group instanceof Group) {
+ return $this
+ ->addUsingAlias(GroupDescPeer::GROUP_ID, $group->getId(), $comparison);
+ } elseif ($group instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupDescPeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Group relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Group');
+
+ // 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, 'Group');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Group relation Group 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\GroupQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param GroupDesc $groupDesc Object to remove from the list of results
+ *
+ * @return GroupDescQuery The current query, for fluid interface
+ */
+ public function prune($groupDesc = null)
+ {
+ if ($groupDesc) {
+ $this->addUsingAlias(GroupDescPeer::ID, $groupDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseGroupModule.php b/core/lib/Thelia/Model/om/BaseGroupModule.php
new file mode 100644
index 000000000..ee1e968de
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupModule.php
@@ -0,0 +1,1320 @@
+access = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseGroupModule object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Get the [group_id] column value.
+ *
+ * @return int
+ */
+ public function getGroupId()
+ {
+ return $this->group_id;
+ }
+
+ /**
+ * Get the [module_id] column value.
+ *
+ * @return int
+ */
+ public function getModuleId()
+ {
+ return $this->module_id;
+ }
+
+ /**
+ * Get the [access] column value.
+ *
+ * @return int
+ */
+ public function getAccess()
+ {
+ return $this->access;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return GroupModule The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = GroupModulePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [group_id] column.
+ *
+ * @param int $v new value
+ * @return GroupModule The current object (for fluent API support)
+ */
+ public function setGroupId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->group_id !== $v) {
+ $this->group_id = $v;
+ $this->modifiedColumns[] = GroupModulePeer::GROUP_ID;
+ }
+
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
+
+ return $this;
+ } // setGroupId()
+
+ /**
+ * Set the value of [module_id] column.
+ *
+ * @param int $v new value
+ * @return GroupModule The current object (for fluent API support)
+ */
+ public function setModuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->module_id !== $v) {
+ $this->module_id = $v;
+ $this->modifiedColumns[] = GroupModulePeer::MODULE_ID;
+ }
+
+ if ($this->aModule !== null && $this->aModule->getId() !== $v) {
+ $this->aModule = null;
+ }
+
+
+ return $this;
+ } // setModuleId()
+
+ /**
+ * Set the value of [access] column.
+ *
+ * @param int $v new value
+ * @return GroupModule The current object (for fluent API support)
+ */
+ public function setAccess($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->access !== $v) {
+ $this->access = $v;
+ $this->modifiedColumns[] = GroupModulePeer::ACCESS;
+ }
+
+
+ return $this;
+ } // setAccess()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return GroupModule The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = GroupModulePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return GroupModule The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = GroupModulePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->access !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->group_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->module_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->access = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = GroupModulePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating GroupModule object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = GroupModulePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aGroup = null;
+ $this->aModule = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = GroupModuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ GroupModulePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = GroupModulePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupModulePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(GroupModulePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(GroupModulePeer::GROUP_ID)) {
+ $modifiedColumns[':p' . $index++] = '`GROUP_ID`';
+ }
+ if ($this->isColumnModified(GroupModulePeer::MODULE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`MODULE_ID`';
+ }
+ if ($this->isColumnModified(GroupModulePeer::ACCESS)) {
+ $modifiedColumns[':p' . $index++] = '`ACCESS`';
+ }
+ if ($this->isColumnModified(GroupModulePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(GroupModulePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `group_module` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`GROUP_ID`':
+ $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT);
+ break;
+ case '`MODULE_ID`':
+ $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT);
+ break;
+ case '`ACCESS`':
+ $stmt->bindValue($identifier, $this->access, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = GroupModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getGroupId();
+ break;
+ case 2:
+ return $this->getModuleId();
+ break;
+ case 3:
+ return $this->getAccess();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()] = true;
+ $keys = GroupModulePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getGroupId(),
+ $keys[2] => $this->getModuleId(),
+ $keys[3] => $this->getAccess(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aModule) {
+ $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = GroupModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setGroupId($value);
+ break;
+ case 2:
+ $this->setModuleId($value);
+ break;
+ case 3:
+ $this->setAccess($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = GroupModulePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setModuleId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setAccess($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(GroupModulePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(GroupModulePeer::ID)) $criteria->add(GroupModulePeer::ID, $this->id);
+ if ($this->isColumnModified(GroupModulePeer::GROUP_ID)) $criteria->add(GroupModulePeer::GROUP_ID, $this->group_id);
+ if ($this->isColumnModified(GroupModulePeer::MODULE_ID)) $criteria->add(GroupModulePeer::MODULE_ID, $this->module_id);
+ if ($this->isColumnModified(GroupModulePeer::ACCESS)) $criteria->add(GroupModulePeer::ACCESS, $this->access);
+ if ($this->isColumnModified(GroupModulePeer::CREATED_AT)) $criteria->add(GroupModulePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(GroupModulePeer::UPDATED_AT)) $criteria->add(GroupModulePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(GroupModulePeer::DATABASE_NAME);
+ $criteria->add(GroupModulePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of GroupModule (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setGroupId($this->getGroupId());
+ $copyObj->setModuleId($this->getModuleId());
+ $copyObj->setAccess($this->getAccess());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return GroupModule Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return GroupModulePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new GroupModulePeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Group object.
+ *
+ * @param Group $v
+ * @return GroupModule The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setGroup(Group $v = null)
+ {
+ 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;
+ }
+
+
+ /**
+ * 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->addGroupModules($this);
+ */
+ }
+
+ return $this->aGroup;
+ }
+
+ /**
+ * Declares an association between this object and a Module object.
+ *
+ * @param Module $v
+ * @return GroupModule The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setModule(Module $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->group_id = null;
+ $this->module_id = null;
+ $this->access = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aGroup = null;
+ $this->aModule = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(GroupModulePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseGroupModulePeer.php b/core/lib/Thelia/Model/om/BaseGroupModulePeer.php
new file mode 100644
index 000000000..4b01ddc66
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupModulePeer.php
@@ -0,0 +1,1421 @@
+ array ('Id', 'GroupId', 'ModuleId', 'Access', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'groupId', 'moduleId', 'access', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (GroupModulePeer::ID, GroupModulePeer::GROUP_ID, GroupModulePeer::MODULE_ID, GroupModulePeer::ACCESS, GroupModulePeer::CREATED_AT, GroupModulePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GROUP_ID', 'MODULE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'group_id', 'module_id', 'access', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. GroupModulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'GroupId' => 1, 'ModuleId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'groupId' => 1, 'moduleId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ BasePeer::TYPE_COLNAME => array (GroupModulePeer::ID => 0, GroupModulePeer::GROUP_ID => 1, GroupModulePeer::MODULE_ID => 2, GroupModulePeer::ACCESS => 3, GroupModulePeer::CREATED_AT => 4, GroupModulePeer::UPDATED_AT => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GROUP_ID' => 1, 'MODULE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'group_id' => 1, 'module_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = GroupModulePeer::getFieldNames($toType);
+ $key = isset(GroupModulePeer::$fieldKeys[$fromType][$name]) ? GroupModulePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(GroupModulePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, GroupModulePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return GroupModulePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. GroupModulePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(GroupModulePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(GroupModulePeer::ID);
+ $criteria->addSelectColumn(GroupModulePeer::GROUP_ID);
+ $criteria->addSelectColumn(GroupModulePeer::MODULE_ID);
+ $criteria->addSelectColumn(GroupModulePeer::ACCESS);
+ $criteria->addSelectColumn(GroupModulePeer::CREATED_AT);
+ $criteria->addSelectColumn(GroupModulePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.GROUP_ID');
+ $criteria->addSelectColumn($alias . '.MODULE_ID');
+ $criteria->addSelectColumn($alias . '.ACCESS');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return GroupModule
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = GroupModulePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return GroupModulePeer::populateObjects(GroupModulePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ GroupModulePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param GroupModule $obj A GroupModule object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ GroupModulePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A GroupModule object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof GroupModule) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or GroupModule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(GroupModulePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return GroupModule Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(GroupModulePeer::$instances[$key])) {
+ return GroupModulePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ GroupModulePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to group_module
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = GroupModulePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = GroupModulePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ GroupModulePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (GroupModule object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = GroupModulePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + GroupModulePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = GroupModulePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ GroupModulePeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(GroupModulePeer::DATABASE_NAME)->getTable(GroupModulePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseGroupModulePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseGroupModulePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new GroupModuleTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return GroupModulePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a GroupModule or Criteria object.
+ *
+ * @param mixed $values Criteria or GroupModule object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from GroupModule object
+ }
+
+ if ($criteria->containsKey(GroupModulePeer::ID) && $criteria->keyContainsValue(GroupModulePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupModulePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a GroupModule or Criteria object.
+ *
+ * @param mixed $values Criteria or GroupModule object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(GroupModulePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(GroupModulePeer::ID);
+ $value = $criteria->remove(GroupModulePeer::ID);
+ if ($value) {
+ $selectCriteria->add(GroupModulePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
+ }
+
+ } else { // $values is GroupModule object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the group_module table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ GroupModulePeer::clearInstancePool();
+ GroupModulePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a GroupModule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or GroupModule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ GroupModulePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given GroupModule object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param GroupModule $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(GroupModulePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(GroupModulePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(GroupModulePeer::DATABASE_NAME, GroupModulePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return GroupModule
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = GroupModulePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(GroupModulePeer::DATABASE_NAME);
+ $criteria->add(GroupModulePeer::ID, $pk);
+
+ $v = GroupModulePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return GroupModule[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(GroupModulePeer::DATABASE_NAME);
+ $criteria->add(GroupModulePeer::ID, $pks, Criteria::IN);
+ $objs = GroupModulePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseGroupModulePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseGroupModulePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php
new file mode 100644
index 000000000..d43848e11
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php
@@ -0,0 +1,654 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return GroupModule|GroupModule[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = GroupModulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return GroupModule A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `GROUP_ID`, `MODULE_ID`, `ACCESS`, `CREATED_AT`, `UPDATED_AT` FROM `group_module` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new GroupModule();
+ $obj->hydrate($row);
+ GroupModulePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return GroupModule|GroupModule[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|GroupModule[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(GroupModulePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(GroupModulePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(GroupModulePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the group_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByGroupId(1234); // WHERE group_id = 1234
+ * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34)
+ * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
+ *
+ *
+ * @see filterByGroup()
+ *
+ * @param mixed $groupId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByGroupId($groupId = null, $comparison = null)
+ {
+ if (is_array($groupId)) {
+ $useMinMax = false;
+ if (isset($groupId['min'])) {
+ $this->addUsingAlias(GroupModulePeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($groupId['max'])) {
+ $this->addUsingAlias(GroupModulePeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModulePeer::GROUP_ID, $groupId, $comparison);
+ }
+
+ /**
+ * Filter the query on the module_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByModuleId(1234); // WHERE module_id = 1234
+ * $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34)
+ * $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
+ *
+ *
+ * @see filterByModule()
+ *
+ * @param mixed $moduleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByModuleId($moduleId = null, $comparison = null)
+ {
+ if (is_array($moduleId)) {
+ $useMinMax = false;
+ if (isset($moduleId['min'])) {
+ $this->addUsingAlias(GroupModulePeer::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($moduleId['max'])) {
+ $this->addUsingAlias(GroupModulePeer::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModulePeer::MODULE_ID, $moduleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the access column
+ *
+ * Example usage:
+ *
+ * $query->filterByAccess(1234); // WHERE access = 1234
+ * $query->filterByAccess(array(12, 34)); // WHERE access IN (12, 34)
+ * $query->filterByAccess(array('min' => 12)); // WHERE access > 12
+ *
+ *
+ * @param mixed $access The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByAccess($access = null, $comparison = null)
+ {
+ if (is_array($access)) {
+ $useMinMax = false;
+ if (isset($access['min'])) {
+ $this->addUsingAlias(GroupModulePeer::ACCESS, $access['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($access['max'])) {
+ $this->addUsingAlias(GroupModulePeer::ACCESS, $access['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModulePeer::ACCESS, $access, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(GroupModulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(GroupModulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModulePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(GroupModulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(GroupModulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModulePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Group object
+ *
+ * @param Group|PropelObjectCollection $group The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroup($group, $comparison = null)
+ {
+ if ($group instanceof Group) {
+ return $this
+ ->addUsingAlias(GroupModulePeer::GROUP_ID, $group->getId(), $comparison);
+ } elseif ($group instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupModulePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Group relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Group');
+
+ // 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, 'Group');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Group relation Group 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\GroupQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
+ }
+
+ /**
+ * Filter the query by a related Module object
+ *
+ * @param Module|PropelObjectCollection $module The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByModule($module, $comparison = null)
+ {
+ if ($module instanceof Module) {
+ return $this
+ ->addUsingAlias(GroupModulePeer::MODULE_ID, $module->getId(), $comparison);
+ } elseif ($module instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupModulePeer::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByModule() only accepts arguments of type Module or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Module relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function joinModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Module');
+
+ // 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, 'Module');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Module relation Module 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\ModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param GroupModule $groupModule Object to remove from the list of results
+ *
+ * @return GroupModuleQuery The current query, for fluid interface
+ */
+ public function prune($groupModule = null)
+ {
+ if ($groupModule) {
+ $this->addUsingAlias(GroupModulePeer::ID, $groupModule->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseGroupPeer.php b/core/lib/Thelia/Model/om/BaseGroupPeer.php
new file mode 100644
index 000000000..ce32ce038
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupPeer.php
@@ -0,0 +1,794 @@
+ array ('Id', 'Code', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (GroupPeer::ID, GroupPeer::CODE, GroupPeer::CREATED_AT, GroupPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. GroupPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ BasePeer::TYPE_COLNAME => array (GroupPeer::ID => 0, GroupPeer::CODE => 1, GroupPeer::CREATED_AT => 2, GroupPeer::UPDATED_AT => 3, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = GroupPeer::getFieldNames($toType);
+ $key = isset(GroupPeer::$fieldKeys[$fromType][$name]) ? GroupPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(GroupPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, GroupPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return GroupPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. GroupPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(GroupPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(GroupPeer::ID);
+ $criteria->addSelectColumn(GroupPeer::CODE);
+ $criteria->addSelectColumn(GroupPeer::CREATED_AT);
+ $criteria->addSelectColumn(GroupPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(GroupPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Group
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = GroupPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return GroupPeer::populateObjects(GroupPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ GroupPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Group $obj A Group object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ GroupPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Group object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Group) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Group object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(GroupPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Group Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(GroupPeer::$instances[$key])) {
+ return GroupPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ GroupPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to group
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = GroupPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = GroupPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = GroupPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ GroupPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Group object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = GroupPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + GroupPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = GroupPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ GroupPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(GroupPeer::DATABASE_NAME)->getTable(GroupPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseGroupPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseGroupPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new GroupTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return GroupPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Group or Criteria object.
+ *
+ * @param mixed $values Criteria or Group object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Group object
+ }
+
+ if ($criteria->containsKey(GroupPeer::ID) && $criteria->keyContainsValue(GroupPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Group or Criteria object.
+ *
+ * @param mixed $values Criteria or Group object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(GroupPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(GroupPeer::ID);
+ $value = $criteria->remove(GroupPeer::ID);
+ if ($value) {
+ $selectCriteria->add(GroupPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(GroupPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Group object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(GroupPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the group table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(GroupPeer::TABLE_NAME, $con, GroupPeer::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
+ // instances get re-added by the select statement contained therein).
+ GroupPeer::clearInstancePool();
+ GroupPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Group or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Group object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ GroupPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Group) { // it's a model object
+ // invalidate the cache for this single object
+ GroupPeer::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(GroupPeer::DATABASE_NAME);
+ $criteria->add(GroupPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ GroupPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ GroupPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Group object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Group $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(GroupPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(GroupPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(GroupPeer::DATABASE_NAME, GroupPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Group
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = GroupPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(GroupPeer::DATABASE_NAME);
+ $criteria->add(GroupPeer::ID, $pk);
+
+ $v = GroupPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Group[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(GroupPeer::DATABASE_NAME);
+ $criteria->add(GroupPeer::ID, $pks, Criteria::IN);
+ $objs = GroupPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseGroupPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseGroupPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseGroupQuery.php b/core/lib/Thelia/Model/om/BaseGroupQuery.php
new file mode 100644
index 000000000..a6f5c29ad
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupQuery.php
@@ -0,0 +1,702 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Group|Group[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = GroupPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Group A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CODE`, `CREATED_AT`, `UPDATED_AT` FROM `group` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Group();
+ $obj->hydrate($row);
+ GroupPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Group|Group[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Group[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(GroupPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(GroupPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(GroupPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupPeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(GroupPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(GroupPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related AdminGroup object
+ *
+ * @param AdminGroup|PropelObjectCollection $adminGroup the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByAdminGroup($adminGroup, $comparison = null)
+ {
+ if ($adminGroup instanceof AdminGroup) {
+ return $this
+ ->addUsingAlias(GroupPeer::ID, $adminGroup->getGroupId(), $comparison);
+ } elseif ($adminGroup instanceof PropelObjectCollection) {
+ return $this
+ ->useAdminGroupQuery()
+ ->filterByPrimaryKeys($adminGroup->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AdminGroup relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function joinAdminGroup($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AdminGroup');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AdminGroup');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AdminGroup relation AdminGroup object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query
+ */
+ public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinAdminGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery');
+ }
+
+ /**
+ * Filter the query by a related GroupDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroupDesc($groupDesc, $comparison = null)
+ {
+ if ($groupDesc instanceof GroupDesc) {
+ return $this
+ ->addUsingAlias(GroupPeer::ID, $groupDesc->getGroupId(), $comparison);
+ } elseif ($groupDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useGroupDescQuery()
+ ->filterByPrimaryKeys($groupDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupDesc() only accepts arguments of type GroupDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function joinGroupDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupDesc');
+
+ // 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, 'GroupDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupDesc relation GroupDesc 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\GroupDescQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroupDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupDesc', '\Thelia\Model\GroupDescQuery');
+ }
+
+ /**
+ * Filter the query by a related GroupModule object
+ *
+ * @param GroupModule|PropelObjectCollection $groupModule the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroupModule($groupModule, $comparison = null)
+ {
+ if ($groupModule instanceof GroupModule) {
+ return $this
+ ->addUsingAlias(GroupPeer::ID, $groupModule->getGroupId(), $comparison);
+ } elseif ($groupModule instanceof PropelObjectCollection) {
+ return $this
+ ->useGroupModuleQuery()
+ ->filterByPrimaryKeys($groupModule->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupModule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function joinGroupModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupModule');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupModule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupModule relation GroupModule object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroupModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery');
+ }
+
+ /**
+ * Filter the query by a related GroupResource object
+ *
+ * @param GroupResource|PropelObjectCollection $groupResource the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroupResource($groupResource, $comparison = null)
+ {
+ if ($groupResource instanceof GroupResource) {
+ return $this
+ ->addUsingAlias(GroupPeer::ID, $groupResource->getGroupId(), $comparison);
+ } elseif ($groupResource instanceof PropelObjectCollection) {
+ return $this
+ ->useGroupResourceQuery()
+ ->filterByPrimaryKeys($groupResource->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupResource relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupResource');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupResource');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupResource relation GroupResource object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroupResource($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Group $group Object to remove from the list of results
+ *
+ * @return GroupQuery The current query, for fluid interface
+ */
+ public function prune($group = null)
+ {
+ if ($group) {
+ $this->addUsingAlias(GroupPeer::ID, $group->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseGroupResource.php b/core/lib/Thelia/Model/om/BaseGroupResource.php
new file mode 100644
index 000000000..19e6b6d32
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupResource.php
@@ -0,0 +1,1381 @@
+read = 0;
+ $this->write = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseGroupResource object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Get the [group_id] column value.
+ *
+ * @return int
+ */
+ public function getGroupId()
+ {
+ return $this->group_id;
+ }
+
+ /**
+ * Get the [resource_id] column value.
+ *
+ * @return int
+ */
+ public function getResourceId()
+ {
+ return $this->resource_id;
+ }
+
+ /**
+ * Get the [read] column value.
+ *
+ * @return int
+ */
+ public function getRead()
+ {
+ return $this->read;
+ }
+
+ /**
+ * Get the [write] column value.
+ *
+ * @return int
+ */
+ public function getWrite()
+ {
+ return $this->write;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return GroupResource The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = GroupResourcePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [group_id] column.
+ *
+ * @param int $v new value
+ * @return GroupResource The current object (for fluent API support)
+ */
+ public function setGroupId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->group_id !== $v) {
+ $this->group_id = $v;
+ $this->modifiedColumns[] = GroupResourcePeer::GROUP_ID;
+ }
+
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
+
+ return $this;
+ } // setGroupId()
+
+ /**
+ * Set the value of [resource_id] column.
+ *
+ * @param int $v new value
+ * @return GroupResource The current object (for fluent API support)
+ */
+ public function setResourceId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->resource_id !== $v) {
+ $this->resource_id = $v;
+ $this->modifiedColumns[] = GroupResourcePeer::RESOURCE_ID;
+ }
+
+ if ($this->aResource !== null && $this->aResource->getId() !== $v) {
+ $this->aResource = null;
+ }
+
+
+ return $this;
+ } // setResourceId()
+
+ /**
+ * Set the value of [read] column.
+ *
+ * @param int $v new value
+ * @return GroupResource The current object (for fluent API support)
+ */
+ public function setRead($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->read !== $v) {
+ $this->read = $v;
+ $this->modifiedColumns[] = GroupResourcePeer::READ;
+ }
+
+
+ return $this;
+ } // setRead()
+
+ /**
+ * Set the value of [write] column.
+ *
+ * @param int $v new value
+ * @return GroupResource The current object (for fluent API support)
+ */
+ public function setWrite($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->write !== $v) {
+ $this->write = $v;
+ $this->modifiedColumns[] = GroupResourcePeer::WRITE;
+ }
+
+
+ return $this;
+ } // setWrite()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return GroupResource The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = GroupResourcePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return GroupResource The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = GroupResourcePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->read !== 0) {
+ return false;
+ }
+
+ if ($this->write !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->group_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->resource_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->read = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->write = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = GroupResourcePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating GroupResource object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = GroupResourcePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aGroup = null;
+ $this->aResource = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = GroupResourceQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ GroupResourcePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = GroupResourcePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupResourcePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(GroupResourcePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(GroupResourcePeer::GROUP_ID)) {
+ $modifiedColumns[':p' . $index++] = '`GROUP_ID`';
+ }
+ if ($this->isColumnModified(GroupResourcePeer::RESOURCE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`RESOURCE_ID`';
+ }
+ if ($this->isColumnModified(GroupResourcePeer::READ)) {
+ $modifiedColumns[':p' . $index++] = '`READ`';
+ }
+ if ($this->isColumnModified(GroupResourcePeer::WRITE)) {
+ $modifiedColumns[':p' . $index++] = '`WRITE`';
+ }
+ if ($this->isColumnModified(GroupResourcePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(GroupResourcePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `group_resource` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`GROUP_ID`':
+ $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT);
+ break;
+ case '`RESOURCE_ID`':
+ $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT);
+ break;
+ case '`READ`':
+ $stmt->bindValue($identifier, $this->read, PDO::PARAM_INT);
+ break;
+ case '`WRITE`':
+ $stmt->bindValue($identifier, $this->write, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = GroupResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getGroupId();
+ break;
+ case 2:
+ return $this->getResourceId();
+ break;
+ case 3:
+ return $this->getRead();
+ break;
+ case 4:
+ return $this->getWrite();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['GroupResource'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['GroupResource'][$this->getPrimaryKey()] = true;
+ $keys = GroupResourcePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getGroupId(),
+ $keys[2] => $this->getResourceId(),
+ $keys[3] => $this->getRead(),
+ $keys[4] => $this->getWrite(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aResource) {
+ $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = GroupResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setGroupId($value);
+ break;
+ case 2:
+ $this->setResourceId($value);
+ break;
+ case 3:
+ $this->setRead($value);
+ break;
+ case 4:
+ $this->setWrite($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = GroupResourcePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setResourceId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setRead($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setWrite($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(GroupResourcePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(GroupResourcePeer::ID)) $criteria->add(GroupResourcePeer::ID, $this->id);
+ if ($this->isColumnModified(GroupResourcePeer::GROUP_ID)) $criteria->add(GroupResourcePeer::GROUP_ID, $this->group_id);
+ if ($this->isColumnModified(GroupResourcePeer::RESOURCE_ID)) $criteria->add(GroupResourcePeer::RESOURCE_ID, $this->resource_id);
+ if ($this->isColumnModified(GroupResourcePeer::READ)) $criteria->add(GroupResourcePeer::READ, $this->read);
+ if ($this->isColumnModified(GroupResourcePeer::WRITE)) $criteria->add(GroupResourcePeer::WRITE, $this->write);
+ if ($this->isColumnModified(GroupResourcePeer::CREATED_AT)) $criteria->add(GroupResourcePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(GroupResourcePeer::UPDATED_AT)) $criteria->add(GroupResourcePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(GroupResourcePeer::DATABASE_NAME);
+ $criteria->add(GroupResourcePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of GroupResource (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setGroupId($this->getGroupId());
+ $copyObj->setResourceId($this->getResourceId());
+ $copyObj->setRead($this->getRead());
+ $copyObj->setWrite($this->getWrite());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return GroupResource Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return GroupResourcePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new GroupResourcePeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Group object.
+ *
+ * @param Group $v
+ * @return GroupResource The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setGroup(Group $v = null)
+ {
+ 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;
+ }
+
+
+ /**
+ * 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->addGroupResources($this);
+ */
+ }
+
+ return $this->aGroup;
+ }
+
+ /**
+ * Declares an association between this object and a Resource object.
+ *
+ * @param Resource $v
+ * @return GroupResource The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setResource(Resource $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->group_id = null;
+ $this->resource_id = null;
+ $this->read = null;
+ $this->write = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aGroup = null;
+ $this->aResource = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(GroupResourcePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php b/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php
new file mode 100644
index 000000000..bfecc6147
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php
@@ -0,0 +1,1426 @@
+ array ('Id', 'GroupId', 'ResourceId', 'Read', 'Write', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'groupId', 'resourceId', 'read', 'write', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (GroupResourcePeer::ID, GroupResourcePeer::GROUP_ID, GroupResourcePeer::RESOURCE_ID, GroupResourcePeer::READ, GroupResourcePeer::WRITE, GroupResourcePeer::CREATED_AT, GroupResourcePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GROUP_ID', 'RESOURCE_ID', 'READ', 'WRITE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'group_id', 'resource_id', 'read', 'write', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. GroupResourcePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'GroupId' => 1, 'ResourceId' => 2, 'Read' => 3, 'Write' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'groupId' => 1, 'resourceId' => 2, 'read' => 3, 'write' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (GroupResourcePeer::ID => 0, GroupResourcePeer::GROUP_ID => 1, GroupResourcePeer::RESOURCE_ID => 2, GroupResourcePeer::READ => 3, GroupResourcePeer::WRITE => 4, GroupResourcePeer::CREATED_AT => 5, GroupResourcePeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GROUP_ID' => 1, 'RESOURCE_ID' => 2, 'READ' => 3, 'WRITE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'group_id' => 1, 'resource_id' => 2, 'read' => 3, 'write' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = GroupResourcePeer::getFieldNames($toType);
+ $key = isset(GroupResourcePeer::$fieldKeys[$fromType][$name]) ? GroupResourcePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(GroupResourcePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, GroupResourcePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return GroupResourcePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. GroupResourcePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(GroupResourcePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(GroupResourcePeer::ID);
+ $criteria->addSelectColumn(GroupResourcePeer::GROUP_ID);
+ $criteria->addSelectColumn(GroupResourcePeer::RESOURCE_ID);
+ $criteria->addSelectColumn(GroupResourcePeer::READ);
+ $criteria->addSelectColumn(GroupResourcePeer::WRITE);
+ $criteria->addSelectColumn(GroupResourcePeer::CREATED_AT);
+ $criteria->addSelectColumn(GroupResourcePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.GROUP_ID');
+ $criteria->addSelectColumn($alias . '.RESOURCE_ID');
+ $criteria->addSelectColumn($alias . '.READ');
+ $criteria->addSelectColumn($alias . '.WRITE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return GroupResource
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = GroupResourcePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return GroupResourcePeer::populateObjects(GroupResourcePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ GroupResourcePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param GroupResource $obj A GroupResource object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ GroupResourcePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A GroupResource object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof GroupResource) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or GroupResource object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(GroupResourcePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return GroupResource Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(GroupResourcePeer::$instances[$key])) {
+ return GroupResourcePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ GroupResourcePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to group_resource
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = GroupResourcePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = GroupResourcePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ GroupResourcePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (GroupResource object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = GroupResourcePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + GroupResourcePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = GroupResourcePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ GroupResourcePeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(GroupResourcePeer::DATABASE_NAME)->getTable(GroupResourcePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseGroupResourcePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseGroupResourcePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new GroupResourceTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return GroupResourcePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a GroupResource or Criteria object.
+ *
+ * @param mixed $values Criteria or GroupResource object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from GroupResource object
+ }
+
+ if ($criteria->containsKey(GroupResourcePeer::ID) && $criteria->keyContainsValue(GroupResourcePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupResourcePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a GroupResource or Criteria object.
+ *
+ * @param mixed $values Criteria or GroupResource object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(GroupResourcePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(GroupResourcePeer::ID);
+ $value = $criteria->remove(GroupResourcePeer::ID);
+ if ($value) {
+ $selectCriteria->add(GroupResourcePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME);
+ }
+
+ } else { // $values is GroupResource object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the group_resource table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ GroupResourcePeer::clearInstancePool();
+ GroupResourcePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a GroupResource or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or GroupResource object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(GroupResourcePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ GroupResourcePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given GroupResource object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param GroupResource $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(GroupResourcePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(GroupResourcePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(GroupResourcePeer::DATABASE_NAME, GroupResourcePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return GroupResource
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = GroupResourcePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(GroupResourcePeer::DATABASE_NAME);
+ $criteria->add(GroupResourcePeer::ID, $pk);
+
+ $v = GroupResourcePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return GroupResource[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(GroupResourcePeer::DATABASE_NAME);
+ $criteria->add(GroupResourcePeer::ID, $pks, Criteria::IN);
+ $objs = GroupResourcePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseGroupResourcePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseGroupResourcePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php
new file mode 100644
index 000000000..da6d5aa02
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php
@@ -0,0 +1,699 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return GroupResource|GroupResource[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = GroupResourcePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return GroupResource A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `GROUP_ID`, `RESOURCE_ID`, `READ`, `WRITE`, `CREATED_AT`, `UPDATED_AT` FROM `group_resource` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new GroupResource();
+ $obj->hydrate($row);
+ GroupResourcePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return GroupResource|GroupResource[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|GroupResource[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(GroupResourcePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(GroupResourcePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(GroupResourcePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the group_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByGroupId(1234); // WHERE group_id = 1234
+ * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34)
+ * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
+ *
+ *
+ * @see filterByGroup()
+ *
+ * @param mixed $groupId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByGroupId($groupId = null, $comparison = null)
+ {
+ if (is_array($groupId)) {
+ $useMinMax = false;
+ if (isset($groupId['min'])) {
+ $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($groupId['max'])) {
+ $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId, $comparison);
+ }
+
+ /**
+ * Filter the query on the resource_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByResourceId(1234); // WHERE resource_id = 1234
+ * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34)
+ * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12
+ *
+ *
+ * @see filterByResource()
+ *
+ * @param mixed $resourceId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByResourceId($resourceId = null, $comparison = null)
+ {
+ if (is_array($resourceId)) {
+ $useMinMax = false;
+ if (isset($resourceId['min'])) {
+ $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($resourceId['max'])) {
+ $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId, $comparison);
+ }
+
+ /**
+ * Filter the query on the read column
+ *
+ * Example usage:
+ *
+ * $query->filterByRead(1234); // WHERE read = 1234
+ * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34)
+ * $query->filterByRead(array('min' => 12)); // WHERE read > 12
+ *
+ *
+ * @param mixed $read The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByRead($read = null, $comparison = null)
+ {
+ if (is_array($read)) {
+ $useMinMax = false;
+ if (isset($read['min'])) {
+ $this->addUsingAlias(GroupResourcePeer::READ, $read['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($read['max'])) {
+ $this->addUsingAlias(GroupResourcePeer::READ, $read['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourcePeer::READ, $read, $comparison);
+ }
+
+ /**
+ * Filter the query on the write column
+ *
+ * Example usage:
+ *
+ * $query->filterByWrite(1234); // WHERE write = 1234
+ * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34)
+ * $query->filterByWrite(array('min' => 12)); // WHERE write > 12
+ *
+ *
+ * @param mixed $write The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByWrite($write = null, $comparison = null)
+ {
+ if (is_array($write)) {
+ $useMinMax = false;
+ if (isset($write['min'])) {
+ $this->addUsingAlias(GroupResourcePeer::WRITE, $write['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($write['max'])) {
+ $this->addUsingAlias(GroupResourcePeer::WRITE, $write['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourcePeer::WRITE, $write, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Group object
+ *
+ * @param Group|PropelObjectCollection $group The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroup($group, $comparison = null)
+ {
+ if ($group instanceof Group) {
+ return $this
+ ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->getId(), $comparison);
+ } elseif ($group instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Group relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Group');
+
+ // 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, 'Group');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Group relation Group 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\GroupQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
+ }
+
+ /**
+ * Filter the query by a related Resource object
+ *
+ * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByResource($resource, $comparison = null)
+ {
+ if ($resource instanceof Resource) {
+ return $this
+ ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->getId(), $comparison);
+ } elseif ($resource instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Resource relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Resource');
+
+ // 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, 'Resource');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Resource relation Resource 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\ResourceQuery A secondary query class using the current class as primary query
+ */
+ public function useResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinResource($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param GroupResource $groupResource Object to remove from the list of results
+ *
+ * @return GroupResourceQuery The current query, for fluid interface
+ */
+ public function prune($groupResource = null)
+ {
+ if ($groupResource) {
+ $this->addUsingAlias(GroupResourcePeer::ID, $groupResource->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseImage.php b/core/lib/Thelia/Model/om/BaseImage.php
new file mode 100644
index 000000000..83f575469
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseImage.php
@@ -0,0 +1,1909 @@
+id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+ return $this->folder_id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [file] column value.
+ *
+ * @return string
+ */
+ public function getFile()
+ {
+ return $this->file;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Image The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ImagePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return Image The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = ImagePeer::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return Image The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = ImagePeer::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return Image The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = ImagePeer::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return Image The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = ImagePeer::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [file] column.
+ *
+ * @param string $v new value
+ * @return Image The current object (for fluent API support)
+ */
+ public function setFile($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->file !== $v) {
+ $this->file = $v;
+ $this->modifiedColumns[] = ImagePeer::FILE;
+ }
+
+
+ return $this;
+ } // setFile()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Image The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ImagePeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Image The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ImagePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Image The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ImagePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->category_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->folder_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->content_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->file = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
+ $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = ImagePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Image object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ImagePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ $this->collImageDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ImageQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ImagePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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->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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ 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->collImageDescs !== null) {
+ foreach ($this->collImageDescs as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ImagePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ImagePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ImagePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ImagePeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(ImagePeer::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`';
+ }
+ if ($this->isColumnModified(ImagePeer::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FOLDER_ID`';
+ }
+ if ($this->isColumnModified(ImagePeer::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CONTENT_ID`';
+ }
+ if ($this->isColumnModified(ImagePeer::FILE)) {
+ $modifiedColumns[':p' . $index++] = '`FILE`';
+ }
+ if ($this->isColumnModified(ImagePeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(ImagePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ImagePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `image` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`CATEGORY_ID`':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case '`FOLDER_ID`':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ case '`CONTENT_ID`':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case '`FILE`':
+ $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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->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 = ImagePeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ if ($this->collImageDescs !== null) {
+ foreach ($this->collImageDescs as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ImagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getProductId();
+ break;
+ case 2:
+ return $this->getCategoryId();
+ break;
+ case 3:
+ return $this->getFolderId();
+ break;
+ case 4:
+ return $this->getContentId();
+ break;
+ case 5:
+ return $this->getFile();
+ break;
+ case 6:
+ return $this->getPosition();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Image'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Image'][$this->getPrimaryKey()] = true;
+ $keys = ImagePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getCategoryId(),
+ $keys[3] => $this->getFolderId(),
+ $keys[4] => $this->getContentId(),
+ $keys[5] => $this->getFile(),
+ $keys[6] => $this->getPosition(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collImageDescs) {
+ $result['ImageDescs'] = $this->collImageDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ImagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setProductId($value);
+ break;
+ case 2:
+ $this->setCategoryId($value);
+ break;
+ case 3:
+ $this->setFolderId($value);
+ break;
+ case 4:
+ $this->setContentId($value);
+ break;
+ case 5:
+ $this->setFile($value);
+ break;
+ case 6:
+ $this->setPosition($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ImagePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ImagePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ImagePeer::ID)) $criteria->add(ImagePeer::ID, $this->id);
+ if ($this->isColumnModified(ImagePeer::PRODUCT_ID)) $criteria->add(ImagePeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(ImagePeer::CATEGORY_ID)) $criteria->add(ImagePeer::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(ImagePeer::FOLDER_ID)) $criteria->add(ImagePeer::FOLDER_ID, $this->folder_id);
+ if ($this->isColumnModified(ImagePeer::CONTENT_ID)) $criteria->add(ImagePeer::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(ImagePeer::FILE)) $criteria->add(ImagePeer::FILE, $this->file);
+ if ($this->isColumnModified(ImagePeer::POSITION)) $criteria->add(ImagePeer::POSITION, $this->position);
+ if ($this->isColumnModified(ImagePeer::CREATED_AT)) $criteria->add(ImagePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ImagePeer::UPDATED_AT)) $criteria->add(ImagePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ImagePeer::DATABASE_NAME);
+ $criteria->add(ImagePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Image (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setFolderId($this->getFolderId());
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setFile($this->getFile());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Image Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ImagePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ImagePeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return Image The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(Product $v = null)
+ {
+ 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->addImage($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->addImages($this);
+ */
+ }
+
+ 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;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('ImageDesc' == $relationName) {
+ $this->initImageDescs();
+ }
+ }
+
+ /**
+ * 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 PropelObjectCollection|ImageDesc[] List of ImageDesc objects
+ * @throws PropelException
+ */
+ 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);
+
+ 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->collImageDescs;
+ }
+
+ /**
+ * 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 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 countImageDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $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();
+ }
+
+ 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;
+ }
+
+ /**
+ * @param ImageDesc $imageDesc The imageDesc object to add.
+ */
+ protected function doAddImageDesc($imageDesc)
+ {
+ $this->collImageDescs[]= $imageDesc;
+ $imageDesc->setImage($this);
+ }
+
+ /**
+ * @param ImageDesc $imageDesc The imageDesc object to remove.
+ */
+ public function removeImageDesc($imageDesc)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->category_id = null;
+ $this->folder_id = null;
+ $this->content_id = null;
+ $this->file = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collImageDescs) {
+ foreach ($this->collImageDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collImageDescs instanceof PropelCollection) {
+ $this->collImageDescs->clearIterator();
+ }
+ $this->collImageDescs = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ImagePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseImageDesc.php b/core/lib/Thelia/Model/om/BaseImageDesc.php
new file mode 100644
index 000000000..baf8e28b9
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseImageDesc.php
@@ -0,0 +1,1265 @@
+id;
+ }
+
+ /**
+ * Get the [image_id] column value.
+ *
+ * @return int
+ */
+ public function getImageId()
+ {
+ return $this->image_id;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ImageDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ImageDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [image_id] column.
+ *
+ * @param int $v new value
+ * @return ImageDesc The current object (for fluent API support)
+ */
+ public function setImageId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->image_id !== $v) {
+ $this->image_id = $v;
+ $this->modifiedColumns[] = ImageDescPeer::IMAGE_ID;
+ }
+
+ if ($this->aImage !== null && $this->aImage->getId() !== $v) {
+ $this->aImage = null;
+ }
+
+
+ return $this;
+ } // setImageId()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return ImageDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ImageDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return ImageDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ImageDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return ImageDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ImageDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ImageDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ImageDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ImageDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ImageDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->image_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = ImageDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ImageDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aImage !== null && $this->image_id !== $this->aImage->getId()) {
+ $this->aImage = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ImageDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aImage = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ImageDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ImageDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ImageDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ImageDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ImageDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ImageDescPeer::IMAGE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`IMAGE_ID`';
+ }
+ if ($this->isColumnModified(ImageDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(ImageDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(ImageDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(ImageDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ImageDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `image_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`IMAGE_ID`':
+ $stmt->bindValue($identifier, $this->image_id, PDO::PARAM_INT);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ImageDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getImageId();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ImageDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ImageDesc'][$this->getPrimaryKey()] = true;
+ $keys = ImageDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getImageId(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aImage) {
+ $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ImageDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setImageId($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ImageDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setImageId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ImageDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ImageDescPeer::ID)) $criteria->add(ImageDescPeer::ID, $this->id);
+ if ($this->isColumnModified(ImageDescPeer::IMAGE_ID)) $criteria->add(ImageDescPeer::IMAGE_ID, $this->image_id);
+ if ($this->isColumnModified(ImageDescPeer::TITLE)) $criteria->add(ImageDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(ImageDescPeer::DESCRIPTION)) $criteria->add(ImageDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ImageDescPeer::CHAPO)) $criteria->add(ImageDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ImageDescPeer::CREATED_AT)) $criteria->add(ImageDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ImageDescPeer::UPDATED_AT)) $criteria->add(ImageDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ImageDescPeer::DATABASE_NAME);
+ $criteria->add(ImageDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ImageDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setImageId($this->getImageId());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ImageDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ImageDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ImageDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Image object.
+ *
+ * @param Image $v
+ * @return ImageDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setImage(Image $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->image_id = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aImage = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ImageDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseImageDescPeer.php b/core/lib/Thelia/Model/om/BaseImageDescPeer.php
new file mode 100644
index 000000000..6025a9ebc
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseImageDescPeer.php
@@ -0,0 +1,1032 @@
+ array ('Id', 'ImageId', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'imageId', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ImageDescPeer::ID, ImageDescPeer::IMAGE_ID, ImageDescPeer::TITLE, ImageDescPeer::DESCRIPTION, ImageDescPeer::CHAPO, ImageDescPeer::CREATED_AT, ImageDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'IMAGE_ID', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'image_id', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ImageDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ImageId' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'imageId' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (ImageDescPeer::ID => 0, ImageDescPeer::IMAGE_ID => 1, ImageDescPeer::TITLE => 2, ImageDescPeer::DESCRIPTION => 3, ImageDescPeer::CHAPO => 4, ImageDescPeer::CREATED_AT => 5, ImageDescPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'IMAGE_ID' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'image_id' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ImageDescPeer::getFieldNames($toType);
+ $key = isset(ImageDescPeer::$fieldKeys[$fromType][$name]) ? ImageDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ImageDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ImageDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ImageDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ImageDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ImageDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ImageDescPeer::ID);
+ $criteria->addSelectColumn(ImageDescPeer::IMAGE_ID);
+ $criteria->addSelectColumn(ImageDescPeer::TITLE);
+ $criteria->addSelectColumn(ImageDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(ImageDescPeer::CHAPO);
+ $criteria->addSelectColumn(ImageDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(ImageDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.IMAGE_ID');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ImageDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ImageDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ImageDescPeer::populateObjects(ImageDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ImageDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ImageDesc $obj A ImageDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ImageDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ImageDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ImageDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ImageDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ImageDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ImageDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ImageDescPeer::$instances[$key])) {
+ return ImageDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ImageDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to image_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ImageDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ImageDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ImageDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ImageDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ImageDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ImageDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ImageDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ImageDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ImageDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ImageDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ImageDescPeer::DATABASE_NAME)->getTable(ImageDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseImageDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseImageDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ImageDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ImageDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ImageDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ImageDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ImageDesc object
+ }
+
+ if ($criteria->containsKey(ImageDescPeer::ID) && $criteria->keyContainsValue(ImageDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ImageDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ImageDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ImageDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ImageDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ImageDescPeer::ID);
+ $value = $criteria->remove(ImageDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ImageDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ImageDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ImageDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the image_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ImageDescPeer::clearInstancePool();
+ ImageDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ImageDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ImageDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ImageDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ImageDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ImageDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ImageDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ImageDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ImageDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ImageDescPeer::DATABASE_NAME, ImageDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return ImageDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ImageDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ImageDescPeer::DATABASE_NAME);
+ $criteria->add(ImageDescPeer::ID, $pk);
+
+ $v = ImageDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return ImageDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ImageDescPeer::DATABASE_NAME);
+ $criteria->add(ImageDescPeer::ID, $pks, Criteria::IN);
+ $objs = ImageDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseImageDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseImageDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseImageDescQuery.php b/core/lib/Thelia/Model/om/BaseImageDescQuery.php
new file mode 100644
index 000000000..e4aba6205
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseImageDescQuery.php
@@ -0,0 +1,580 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ImageDesc|ImageDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ImageDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ImageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ImageDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `IMAGE_ID`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `image_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ImageDesc();
+ $obj->hydrate($row);
+ ImageDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ImageDesc|ImageDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ImageDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ImageDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ImageDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ImageDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the image_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByImageId(1234); // WHERE image_id = 1234
+ * $query->filterByImageId(array(12, 34)); // WHERE image_id IN (12, 34)
+ * $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.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterByImageId($imageId = null, $comparison = null)
+ {
+ if (is_array($imageId)) {
+ $useMinMax = false;
+ if (isset($imageId['min'])) {
+ $this->addUsingAlias(ImageDescPeer::IMAGE_ID, $imageId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($imageId['max'])) {
+ $this->addUsingAlias(ImageDescPeer::IMAGE_ID, $imageId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageDescPeer::IMAGE_ID, $imageId, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ImageDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ImageDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ImageDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ImageDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Image object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof Image) {
+ return $this
+ ->addUsingAlias(ImageDescPeer::IMAGE_ID, $image->getId(), $comparison);
+ } elseif ($image instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImageDescPeer::IMAGE_ID, $image->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ImageDesc $imageDesc Object to remove from the list of results
+ *
+ * @return ImageDescQuery The current query, for fluid interface
+ */
+ public function prune($imageDesc = null)
+ {
+ if ($imageDesc) {
+ $this->addUsingAlias(ImageDescPeer::ID, $imageDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseImagePeer.php b/core/lib/Thelia/Model/om/BaseImagePeer.php
new file mode 100644
index 000000000..d529374bd
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseImagePeer.php
@@ -0,0 +1,2186 @@
+ array ('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ImagePeer::ID, ImagePeer::PRODUCT_ID, ImagePeer::CATEGORY_ID, ImagePeer::FOLDER_ID, ImagePeer::CONTENT_ID, ImagePeer::FILE, ImagePeer::POSITION, ImagePeer::CREATED_AT, ImagePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ImagePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ BasePeer::TYPE_COLNAME => array (ImagePeer::ID => 0, ImagePeer::PRODUCT_ID => 1, ImagePeer::CATEGORY_ID => 2, ImagePeer::FOLDER_ID => 3, ImagePeer::CONTENT_ID => 4, ImagePeer::FILE => 5, ImagePeer::POSITION => 6, ImagePeer::CREATED_AT => 7, ImagePeer::UPDATED_AT => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'CATEGORY_ID' => 2, 'FOLDER_ID' => 3, 'CONTENT_ID' => 4, 'FILE' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'category_id' => 2, 'folder_id' => 3, 'content_id' => 4, 'file' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ImagePeer::getFieldNames($toType);
+ $key = isset(ImagePeer::$fieldKeys[$fromType][$name]) ? ImagePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ImagePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ImagePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ImagePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ImagePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ImagePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ImagePeer::ID);
+ $criteria->addSelectColumn(ImagePeer::PRODUCT_ID);
+ $criteria->addSelectColumn(ImagePeer::CATEGORY_ID);
+ $criteria->addSelectColumn(ImagePeer::FOLDER_ID);
+ $criteria->addSelectColumn(ImagePeer::CONTENT_ID);
+ $criteria->addSelectColumn(ImagePeer::FILE);
+ $criteria->addSelectColumn(ImagePeer::POSITION);
+ $criteria->addSelectColumn(ImagePeer::CREATED_AT);
+ $criteria->addSelectColumn(ImagePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.FILE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ImagePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Image
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ImagePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ImagePeer::populateObjects(ImagePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ImagePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Image $obj A Image object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ImagePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Image object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Image) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Image object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ImagePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Image Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ImagePeer::$instances[$key])) {
+ return ImagePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ImagePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to image
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ImageDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ImageDescPeer::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ImagePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ImagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ImagePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ImagePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Image object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ImagePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ImagePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ImagePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ImagePeer::addInstanceToPool($obj, $key);
+ }
+
+ 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(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::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(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
+ * @return array Array of Image 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(ImagePeer::DATABASE_NAME);
+ }
+
+ ImagePeer::addSelectColumns($criteria);
+ $startcol = ImagePeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::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 = 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 (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
+
+ $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(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::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);
+
+ if ($row = $stmt->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.
+ *
+ * @param 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 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(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;
+
+ 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();
+
+ 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 loaded
+
+ // 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();
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ImagePeer::DATABASE_NAME)->getTable(ImagePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseImagePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseImagePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ImageTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ImagePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Image or Criteria object.
+ *
+ * @param mixed $values Criteria or Image object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Image object
+ }
+
+ if ($criteria->containsKey(ImagePeer::ID) && $criteria->keyContainsValue(ImagePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ImagePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Image or Criteria object.
+ *
+ * @param mixed $values Criteria or Image object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ImagePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ImagePeer::ID);
+ $value = $criteria->remove(ImagePeer::ID);
+ if ($value) {
+ $selectCriteria->add(ImagePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ImagePeer::TABLE_NAME);
+ }
+
+ } else { // $values is Image object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the image table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ImagePeer::clearInstancePool();
+ ImagePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Image or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Image object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ImagePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ImagePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Image object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Image $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ImagePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ImagePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ImagePeer::DATABASE_NAME, ImagePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Image
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ImagePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ImagePeer::DATABASE_NAME);
+ $criteria->add(ImagePeer::ID, $pk);
+
+ $v = ImagePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Image[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ImagePeer::DATABASE_NAME);
+ $criteria->add(ImagePeer::ID, $pks, Criteria::IN);
+ $objs = ImagePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseImagePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseImagePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseImageQuery.php b/core/lib/Thelia/Model/om/BaseImageQuery.php
new file mode 100644
index 000000000..e4e390da2
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseImageQuery.php
@@ -0,0 +1,1022 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Image|Image[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ImagePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Image A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PRODUCT_ID`, `CATEGORY_ID`, `FOLDER_ID`, `CONTENT_ID`, `FILE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `image` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Image();
+ $obj->hydrate($row);
+ ImagePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Image|Image[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Image[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ImagePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ImagePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ImagePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(ImagePeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(ImagePeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImagePeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(ImagePeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(ImagePeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImagePeer::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId)) {
+ $useMinMax = false;
+ if (isset($folderId['min'])) {
+ $this->addUsingAlias(ImagePeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($folderId['max'])) {
+ $this->addUsingAlias(ImagePeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImagePeer::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(ImagePeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(ImagePeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImagePeer::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the file column
+ *
+ * Example usage:
+ *
+ * $query->filterByFile('fooValue'); // WHERE file = 'fooValue'
+ * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%'
+ *
+ *
+ * @param string $file The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByFile($file = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($file)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $file)) {
+ $file = str_replace('*', '%', $file);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImagePeer::FILE, $file, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ImagePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ImagePeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImagePeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ImagePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ImagePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImagePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ImagePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ImagePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImagePeer::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 ImageQuery 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(ImagePeer::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImagePeer::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 ImageQuery 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 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
+ *
+ * @param Image $image Object to remove from the list of results
+ *
+ * @return ImageQuery The current query, for fluid interface
+ */
+ public function prune($image = null)
+ {
+ if ($image) {
+ $this->addUsingAlias(ImagePeer::ID, $image->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseLang.php b/core/lib/Thelia/Model/om/BaseLang.php
new file mode 100644
index 000000000..b3d1f23fb
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseLang.php
@@ -0,0 +1,1156 @@
+id;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [url] column value.
+ *
+ * @return string
+ */
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ /**
+ * Get the [default_utility] column value.
+ *
+ * @return int
+ */
+ public function getDefaultUtility()
+ {
+ return $this->default_utility;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Lang The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = LangPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return Lang The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = LangPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return Lang The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = LangPeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [url] column.
+ *
+ * @param string $v new value
+ * @return Lang The current object (for fluent API support)
+ */
+ public function setUrl($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->url !== $v) {
+ $this->url = $v;
+ $this->modifiedColumns[] = LangPeer::URL;
+ }
+
+
+ return $this;
+ } // setUrl()
+
+ /**
+ * Set the value of [default_utility] column.
+ *
+ * @param int $v new value
+ * @return Lang The current object (for fluent API support)
+ */
+ public function setDefaultUtility($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->default_utility !== $v) {
+ $this->default_utility = $v;
+ $this->modifiedColumns[] = LangPeer::DEFAULT_UTILITY;
+ }
+
+
+ return $this;
+ } // setDefaultUtility()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Lang The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = LangPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Lang The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = LangPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->title = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->code = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->url = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->default_utility = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = LangPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Lang object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = LangPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = LangQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ LangPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = LangPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . LangPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(LangPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(LangPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(LangPeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(LangPeer::URL)) {
+ $modifiedColumns[':p' . $index++] = '`URL`';
+ }
+ if ($this->isColumnModified(LangPeer::DEFAULT_UTILITY)) {
+ $modifiedColumns[':p' . $index++] = '`DEFAULT_UTILITY`';
+ }
+ if ($this->isColumnModified(LangPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(LangPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `lang` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`URL`':
+ $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
+ break;
+ case '`DEFAULT_UTILITY`':
+ $stmt->bindValue($identifier, $this->default_utility, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ if (($retval = LangPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = LangPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getTitle();
+ break;
+ case 2:
+ return $this->getCode();
+ break;
+ case 3:
+ return $this->getUrl();
+ break;
+ case 4:
+ return $this->getDefaultUtility();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
+ {
+ if (isset($alreadyDumpedObjects['Lang'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Lang'][$this->getPrimaryKey()] = true;
+ $keys = LangPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTitle(),
+ $keys[2] => $this->getCode(),
+ $keys[3] => $this->getUrl(),
+ $keys[4] => $this->getDefaultUtility(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = LangPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setTitle($value);
+ break;
+ case 2:
+ $this->setCode($value);
+ break;
+ case 3:
+ $this->setUrl($value);
+ break;
+ case 4:
+ $this->setDefaultUtility($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = LangPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUrl($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDefaultUtility($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(LangPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(LangPeer::ID)) $criteria->add(LangPeer::ID, $this->id);
+ if ($this->isColumnModified(LangPeer::TITLE)) $criteria->add(LangPeer::TITLE, $this->title);
+ if ($this->isColumnModified(LangPeer::CODE)) $criteria->add(LangPeer::CODE, $this->code);
+ if ($this->isColumnModified(LangPeer::URL)) $criteria->add(LangPeer::URL, $this->url);
+ if ($this->isColumnModified(LangPeer::DEFAULT_UTILITY)) $criteria->add(LangPeer::DEFAULT_UTILITY, $this->default_utility);
+ if ($this->isColumnModified(LangPeer::CREATED_AT)) $criteria->add(LangPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(LangPeer::UPDATED_AT)) $criteria->add(LangPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(LangPeer::DATABASE_NAME);
+ $criteria->add(LangPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Lang (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setCode($this->getCode());
+ $copyObj->setUrl($this->getUrl());
+ $copyObj->setDefaultUtility($this->getDefaultUtility());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Lang Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return LangPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new LangPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->title = null;
+ $this->code = null;
+ $this->url = null;
+ $this->default_utility = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(LangPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseLangPeer.php b/core/lib/Thelia/Model/om/BaseLangPeer.php
new file mode 100644
index 000000000..4282c0a19
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseLangPeer.php
@@ -0,0 +1,793 @@
+ array ('Id', 'Title', 'Code', 'Url', 'DefaultUtility', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'title', 'code', 'url', 'defaultUtility', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (LangPeer::ID, LangPeer::TITLE, LangPeer::CODE, LangPeer::URL, LangPeer::DEFAULT_UTILITY, LangPeer::CREATED_AT, LangPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TITLE', 'CODE', 'URL', 'DEFAULT_UTILITY', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'code', 'url', 'default_utility', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. LangPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Code' => 2, 'Url' => 3, 'DefaultUtility' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'url' => 3, 'defaultUtility' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (LangPeer::ID => 0, LangPeer::TITLE => 1, LangPeer::CODE => 2, LangPeer::URL => 3, LangPeer::DEFAULT_UTILITY => 4, LangPeer::CREATED_AT => 5, LangPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'URL' => 3, 'DEFAULT_UTILITY' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'url' => 3, 'default_utility' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = LangPeer::getFieldNames($toType);
+ $key = isset(LangPeer::$fieldKeys[$fromType][$name]) ? LangPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(LangPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, LangPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return LangPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. LangPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(LangPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(LangPeer::ID);
+ $criteria->addSelectColumn(LangPeer::TITLE);
+ $criteria->addSelectColumn(LangPeer::CODE);
+ $criteria->addSelectColumn(LangPeer::URL);
+ $criteria->addSelectColumn(LangPeer::DEFAULT_UTILITY);
+ $criteria->addSelectColumn(LangPeer::CREATED_AT);
+ $criteria->addSelectColumn(LangPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.URL');
+ $criteria->addSelectColumn($alias . '.DEFAULT_UTILITY');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(LangPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ LangPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(LangPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Lang
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = LangPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return LangPeer::populateObjects(LangPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ LangPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(LangPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Lang $obj A Lang object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ LangPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Lang object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Lang) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Lang object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(LangPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Lang Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(LangPeer::$instances[$key])) {
+ return LangPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ LangPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to lang
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = LangPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = LangPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = LangPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ LangPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Lang object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = LangPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = LangPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + LangPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = LangPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ LangPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(LangPeer::DATABASE_NAME)->getTable(LangPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseLangPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseLangPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new LangTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return LangPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Lang or Criteria object.
+ *
+ * @param mixed $values Criteria or Lang object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Lang object
+ }
+
+ if ($criteria->containsKey(LangPeer::ID) && $criteria->keyContainsValue(LangPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.LangPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(LangPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Lang or Criteria object.
+ *
+ * @param mixed $values Criteria or Lang object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(LangPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(LangPeer::ID);
+ $value = $criteria->remove(LangPeer::ID);
+ if ($value) {
+ $selectCriteria->add(LangPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(LangPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Lang object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(LangPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the lang table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(LangPeer::TABLE_NAME, $con, LangPeer::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
+ // instances get re-added by the select statement contained therein).
+ LangPeer::clearInstancePool();
+ LangPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Lang or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Lang object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ LangPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Lang) { // it's a model object
+ // invalidate the cache for this single object
+ LangPeer::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(LangPeer::DATABASE_NAME);
+ $criteria->add(LangPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ LangPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(LangPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ LangPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Lang object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Lang $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(LangPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(LangPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(LangPeer::DATABASE_NAME, LangPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Lang
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = LangPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(LangPeer::DATABASE_NAME);
+ $criteria->add(LangPeer::ID, $pk);
+
+ $v = LangPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Lang[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(LangPeer::DATABASE_NAME);
+ $criteria->add(LangPeer::ID, $pks, Criteria::IN);
+ $objs = LangPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseLangPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseLangPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseLangQuery.php b/core/lib/Thelia/Model/om/BaseLangQuery.php
new file mode 100644
index 000000000..0e084a87d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseLangQuery.php
@@ -0,0 +1,495 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Lang|Lang[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = LangPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Lang A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `TITLE`, `CODE`, `URL`, `DEFAULT_UTILITY`, `CREATED_AT`, `UPDATED_AT` FROM `lang` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Lang();
+ $obj->hydrate($row);
+ LangPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Lang|Lang[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Lang[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(LangPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(LangPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(LangPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(LangPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(LangPeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the url column
+ *
+ * Example usage:
+ *
+ * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue'
+ * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%'
+ *
+ *
+ * @param string $url The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterByUrl($url = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($url)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $url)) {
+ $url = str_replace('*', '%', $url);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(LangPeer::URL, $url, $comparison);
+ }
+
+ /**
+ * Filter the query on the default_utility column
+ *
+ * Example usage:
+ *
+ * $query->filterByDefaultUtility(1234); // WHERE default_utility = 1234
+ * $query->filterByDefaultUtility(array(12, 34)); // WHERE default_utility IN (12, 34)
+ * $query->filterByDefaultUtility(array('min' => 12)); // WHERE default_utility > 12
+ *
+ *
+ * @param mixed $defaultUtility The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterByDefaultUtility($defaultUtility = null, $comparison = null)
+ {
+ if (is_array($defaultUtility)) {
+ $useMinMax = false;
+ if (isset($defaultUtility['min'])) {
+ $this->addUsingAlias(LangPeer::DEFAULT_UTILITY, $defaultUtility['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($defaultUtility['max'])) {
+ $this->addUsingAlias(LangPeer::DEFAULT_UTILITY, $defaultUtility['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(LangPeer::DEFAULT_UTILITY, $defaultUtility, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Lang $lang Object to remove from the list of results
+ *
+ * @return LangQuery The current query, for fluid interface
+ */
+ public function prune($lang = null)
+ {
+ if ($lang) {
+ $this->addUsingAlias(LangPeer::ID, $lang->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseMessage.php b/core/lib/Thelia/Model/om/BaseMessage.php
new file mode 100644
index 000000000..6f3fb5622
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessage.php
@@ -0,0 +1,1345 @@
+id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [secure] column value.
+ *
+ * @return int
+ */
+ public function getSecure()
+ {
+ return $this->secure;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Message The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = MessagePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return Message The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = MessagePeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [secure] column.
+ *
+ * @param int $v new value
+ * @return Message The current object (for fluent API support)
+ */
+ public function setSecure($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->secure !== $v) {
+ $this->secure = $v;
+ $this->modifiedColumns[] = MessagePeer::SECURE;
+ }
+
+
+ return $this;
+ } // setSecure()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Message The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = MessagePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Message The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = MessagePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->secure = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = MessagePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Message object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = MessagePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collMessageDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = MessageQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ MessagePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = MessagePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . MessagePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(MessagePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(MessagePeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(MessagePeer::SECURE)) {
+ $modifiedColumns[':p' . $index++] = '`SECURE`';
+ }
+ if ($this->isColumnModified(MessagePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(MessagePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `message` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`SECURE`':
+ $stmt->bindValue($identifier, $this->secure, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getSecure();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Message'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Message'][$this->getPrimaryKey()] = true;
+ $keys = MessagePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getSecure(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collMessageDescs) {
+ $result['MessageDescs'] = $this->collMessageDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setSecure($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = MessagePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setSecure($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(MessagePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(MessagePeer::ID)) $criteria->add(MessagePeer::ID, $this->id);
+ if ($this->isColumnModified(MessagePeer::CODE)) $criteria->add(MessagePeer::CODE, $this->code);
+ if ($this->isColumnModified(MessagePeer::SECURE)) $criteria->add(MessagePeer::SECURE, $this->secure);
+ if ($this->isColumnModified(MessagePeer::CREATED_AT)) $criteria->add(MessagePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(MessagePeer::UPDATED_AT)) $criteria->add(MessagePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(MessagePeer::DATABASE_NAME);
+ $criteria->add(MessagePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Message (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setSecure($this->getSecure());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Message Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return MessagePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new MessagePeer();
+ }
+
+ 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.
+ *
+ * @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 getMessageDescs($criteria = null, PropelPDO $con = 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 {
+ return count($this->collMessageDescs);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * @param MessageDesc $messageDesc The messageDesc object to remove.
+ */
+ public function removeMessageDesc($messageDesc)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->secure = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collMessageDescs) {
+ foreach ($this->collMessageDescs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collMessageDescs instanceof PropelCollection) {
+ $this->collMessageDescs->clearIterator();
+ }
+ $this->collMessageDescs = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(MessagePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseMessageDesc.php b/core/lib/Thelia/Model/om/BaseMessageDesc.php
new file mode 100644
index 000000000..12caa4890
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessageDesc.php
@@ -0,0 +1,1291 @@
+id;
+ }
+
+ /**
+ * Get the [message_id] column value.
+ *
+ * @return int
+ */
+ public function getMessageId()
+ {
+ return $this->message_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [description_html] column value.
+ *
+ * @return string
+ */
+ public function getDescriptionHtml()
+ {
+ return $this->description_html;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [updated_at] column value.
+ *
+ * @return string
+ */
+ public function getUpdatedAt()
+ {
+ return $this->updated_at;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return MessageDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = MessageDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [message_id] column.
+ *
+ * @param int $v new value
+ * @return MessageDesc The current object (for fluent API support)
+ */
+ public function setMessageId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->message_id !== $v) {
+ $this->message_id = $v;
+ $this->modifiedColumns[] = MessageDescPeer::MESSAGE_ID;
+ }
+
+ if ($this->aMessage !== null && $this->aMessage->getId() !== $v) {
+ $this->aMessage = null;
+ }
+
+
+ return $this;
+ } // setMessageId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return MessageDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = MessageDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return MessageDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = MessageDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return MessageDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = MessageDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [description_html] column.
+ *
+ * @param string $v new value
+ * @return MessageDesc The current object (for fluent API support)
+ */
+ public function setDescriptionHtml($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description_html !== $v) {
+ $this->description_html = $v;
+ $this->modifiedColumns[] = MessageDescPeer::DESCRIPTION_HTML;
+ }
+
+
+ return $this;
+ } // setDescriptionHtml()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return MessageDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = MessageDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Set the value of [updated_at] column.
+ *
+ * @param string $v new value
+ * @return MessageDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->updated_at !== $v) {
+ $this->updated_at = $v;
+ $this->modifiedColumns[] = MessageDescPeer::UPDATED_AT;
+ }
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->message_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->description_html = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = MessageDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating MessageDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aMessage !== null && $this->message_id !== $this->aMessage->getId()) {
+ $this->aMessage = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = MessageDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aMessage = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = MessageDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ MessageDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = MessageDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . MessageDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(MessageDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(MessageDescPeer::MESSAGE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`MESSAGE_ID`';
+ }
+ if ($this->isColumnModified(MessageDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(MessageDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(MessageDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(MessageDescPeer::DESCRIPTION_HTML)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION_HTML`';
+ }
+ if ($this->isColumnModified(MessageDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(MessageDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `message_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`MESSAGE_ID`':
+ $stmt->bindValue($identifier, $this->message_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION_HTML`':
+ $stmt->bindValue($identifier, $this->description_html, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = MessageDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getMessageId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getDescriptionHtml();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['MessageDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['MessageDesc'][$this->getPrimaryKey()] = true;
+ $keys = MessageDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getMessageId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getDescriptionHtml(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aMessage) {
+ $result['Message'] = $this->aMessage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = MessageDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setMessageId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setDescriptionHtml($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = MessageDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setMessageId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setDescriptionHtml($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(MessageDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(MessageDescPeer::ID)) $criteria->add(MessageDescPeer::ID, $this->id);
+ if ($this->isColumnModified(MessageDescPeer::MESSAGE_ID)) $criteria->add(MessageDescPeer::MESSAGE_ID, $this->message_id);
+ if ($this->isColumnModified(MessageDescPeer::LANG)) $criteria->add(MessageDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(MessageDescPeer::TITLE)) $criteria->add(MessageDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(MessageDescPeer::DESCRIPTION)) $criteria->add(MessageDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(MessageDescPeer::DESCRIPTION_HTML)) $criteria->add(MessageDescPeer::DESCRIPTION_HTML, $this->description_html);
+ if ($this->isColumnModified(MessageDescPeer::CREATED_AT)) $criteria->add(MessageDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(MessageDescPeer::UPDATED_AT)) $criteria->add(MessageDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(MessageDescPeer::DATABASE_NAME);
+ $criteria->add(MessageDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of MessageDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setMessageId($this->getMessageId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setDescriptionHtml($this->getDescriptionHtml());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return MessageDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return MessageDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new MessageDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Message object.
+ *
+ * @param Message $v
+ * @return MessageDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setMessage(Message $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->message_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->description_html = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aMessage = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(MessageDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseMessageDescPeer.php b/core/lib/Thelia/Model/om/BaseMessageDescPeer.php
new file mode 100644
index 000000000..ec5f519ff
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessageDescPeer.php
@@ -0,0 +1,1037 @@
+ array ('Id', 'MessageId', 'Lang', 'Title', 'Description', 'DescriptionHtml', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'messageId', 'lang', 'title', 'description', 'descriptionHtml', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (MessageDescPeer::ID, MessageDescPeer::MESSAGE_ID, MessageDescPeer::LANG, MessageDescPeer::TITLE, MessageDescPeer::DESCRIPTION, MessageDescPeer::DESCRIPTION_HTML, MessageDescPeer::CREATED_AT, MessageDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'MESSAGE_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'DESCRIPTION_HTML', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'message_id', 'lang', 'title', 'description', 'description_html', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. MessageDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'MessageId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'DescriptionHtml' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'messageId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'descriptionHtml' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (MessageDescPeer::ID => 0, MessageDescPeer::MESSAGE_ID => 1, MessageDescPeer::LANG => 2, MessageDescPeer::TITLE => 3, MessageDescPeer::DESCRIPTION => 4, MessageDescPeer::DESCRIPTION_HTML => 5, MessageDescPeer::CREATED_AT => 6, MessageDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'MESSAGE_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'DESCRIPTION_HTML' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'message_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'description_html' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = MessageDescPeer::getFieldNames($toType);
+ $key = isset(MessageDescPeer::$fieldKeys[$fromType][$name]) ? MessageDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(MessageDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, MessageDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return MessageDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. MessageDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(MessageDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(MessageDescPeer::ID);
+ $criteria->addSelectColumn(MessageDescPeer::MESSAGE_ID);
+ $criteria->addSelectColumn(MessageDescPeer::LANG);
+ $criteria->addSelectColumn(MessageDescPeer::TITLE);
+ $criteria->addSelectColumn(MessageDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(MessageDescPeer::DESCRIPTION_HTML);
+ $criteria->addSelectColumn(MessageDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(MessageDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.MESSAGE_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION_HTML');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return MessageDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = MessageDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return MessageDescPeer::populateObjects(MessageDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ MessageDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param MessageDesc $obj A MessageDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ MessageDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A MessageDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof MessageDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or MessageDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(MessageDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return MessageDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(MessageDescPeer::$instances[$key])) {
+ return MessageDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ MessageDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to message_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = MessageDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = MessageDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = MessageDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ MessageDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (MessageDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = MessageDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = MessageDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + MessageDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = MessageDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ MessageDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(MessageDescPeer::DATABASE_NAME)->getTable(MessageDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseMessageDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseMessageDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new MessageDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return MessageDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a MessageDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or MessageDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from MessageDesc object
+ }
+
+ if ($criteria->containsKey(MessageDescPeer::ID) && $criteria->keyContainsValue(MessageDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.MessageDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a MessageDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or MessageDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(MessageDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(MessageDescPeer::ID);
+ $value = $criteria->remove(MessageDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(MessageDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(MessageDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is MessageDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the message_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ MessageDescPeer::clearInstancePool();
+ MessageDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a MessageDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or MessageDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(MessageDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ MessageDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given MessageDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param MessageDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(MessageDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(MessageDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(MessageDescPeer::DATABASE_NAME, MessageDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return MessageDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = MessageDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(MessageDescPeer::DATABASE_NAME);
+ $criteria->add(MessageDescPeer::ID, $pk);
+
+ $v = MessageDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return MessageDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(MessageDescPeer::DATABASE_NAME);
+ $criteria->add(MessageDescPeer::ID, $pks, Criteria::IN);
+ $objs = MessageDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseMessageDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseMessageDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseMessageDescQuery.php b/core/lib/Thelia/Model/om/BaseMessageDescQuery.php
new file mode 100644
index 000000000..b5d67bb4e
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessageDescQuery.php
@@ -0,0 +1,599 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return MessageDesc|MessageDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = MessageDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(MessageDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return MessageDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `MESSAGE_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `DESCRIPTION_HTML`, `CREATED_AT`, `UPDATED_AT` FROM `message_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new MessageDesc();
+ $obj->hydrate($row);
+ MessageDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return MessageDesc|MessageDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|MessageDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(MessageDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(MessageDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(MessageDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the message_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByMessageId(1234); // WHERE message_id = 1234
+ * $query->filterByMessageId(array(12, 34)); // WHERE message_id IN (12, 34)
+ * $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.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByMessageId($messageId = null, $comparison = null)
+ {
+ if (is_array($messageId)) {
+ $useMinMax = false;
+ if (isset($messageId['min'])) {
+ $this->addUsingAlias(MessageDescPeer::MESSAGE_ID, $messageId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($messageId['max'])) {
+ $this->addUsingAlias(MessageDescPeer::MESSAGE_ID, $messageId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageDescPeer::MESSAGE_ID, $messageId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the description_html column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescriptionHtml('fooValue'); // WHERE description_html = 'fooValue'
+ * $query->filterByDescriptionHtml('%fooValue%'); // WHERE description_html LIKE '%fooValue%'
+ *
+ *
+ * @param string $descriptionHtml The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByDescriptionHtml($descriptionHtml = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($descriptionHtml)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $descriptionHtml)) {
+ $descriptionHtml = str_replace('*', '%', $descriptionHtml);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageDescPeer::DESCRIPTION_HTML, $descriptionHtml, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(MessageDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(MessageDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('fooValue'); // WHERE updated_at = 'fooValue'
+ * $query->filterByUpdatedAt('%fooValue%'); // WHERE updated_at LIKE '%fooValue%'
+ *
+ *
+ * @param string $updatedAt The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($updatedAt)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $updatedAt)) {
+ $updatedAt = str_replace('*', '%', $updatedAt);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Message object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByMessage($message, $comparison = null)
+ {
+ if ($message instanceof Message) {
+ return $this
+ ->addUsingAlias(MessageDescPeer::MESSAGE_ID, $message->getId(), $comparison);
+ } elseif ($message instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(MessageDescPeer::MESSAGE_ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByMessage() only accepts arguments of type Message or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Message relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function joinMessage($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Message');
+
+ // 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, 'Message');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Message relation Message 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\MessageQuery A secondary query class using the current class as primary query
+ */
+ public function useMessageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinMessage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Message', '\Thelia\Model\MessageQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param MessageDesc $messageDesc Object to remove from the list of results
+ *
+ * @return MessageDescQuery The current query, for fluid interface
+ */
+ public function prune($messageDesc = null)
+ {
+ if ($messageDesc) {
+ $this->addUsingAlias(MessageDescPeer::ID, $messageDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseMessagePeer.php b/core/lib/Thelia/Model/om/BaseMessagePeer.php
new file mode 100644
index 000000000..822db1936
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessagePeer.php
@@ -0,0 +1,787 @@
+ array ('Id', 'Code', 'Secure', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'secure', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (MessagePeer::ID, MessagePeer::CODE, MessagePeer::SECURE, MessagePeer::CREATED_AT, MessagePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'SECURE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'secure', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. MessagePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Secure' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'secure' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ BasePeer::TYPE_COLNAME => array (MessagePeer::ID => 0, MessagePeer::CODE => 1, MessagePeer::SECURE => 2, MessagePeer::CREATED_AT => 3, MessagePeer::UPDATED_AT => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'SECURE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'secure' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = MessagePeer::getFieldNames($toType);
+ $key = isset(MessagePeer::$fieldKeys[$fromType][$name]) ? MessagePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(MessagePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, MessagePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return MessagePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. MessagePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(MessagePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(MessagePeer::ID);
+ $criteria->addSelectColumn(MessagePeer::CODE);
+ $criteria->addSelectColumn(MessagePeer::SECURE);
+ $criteria->addSelectColumn(MessagePeer::CREATED_AT);
+ $criteria->addSelectColumn(MessagePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.SECURE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(MessagePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Message
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = MessagePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return MessagePeer::populateObjects(MessagePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ MessagePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(MessagePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Message $obj A Message object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ MessagePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Message object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Message) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Message object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(MessagePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Message Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(MessagePeer::$instances[$key])) {
+ return MessagePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ MessagePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to message
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = MessagePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = MessagePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = MessagePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ MessagePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Message object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = MessagePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = MessagePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + MessagePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = MessagePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ MessagePeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(MessagePeer::DATABASE_NAME)->getTable(MessagePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseMessagePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseMessagePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new MessageTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return MessagePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Message or Criteria object.
+ *
+ * @param mixed $values Criteria or Message object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Message object
+ }
+
+ if ($criteria->containsKey(MessagePeer::ID) && $criteria->keyContainsValue(MessagePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.MessagePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(MessagePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Message or Criteria object.
+ *
+ * @param mixed $values Criteria or Message object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(MessagePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(MessagePeer::ID);
+ $value = $criteria->remove(MessagePeer::ID);
+ if ($value) {
+ $selectCriteria->add(MessagePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(MessagePeer::TABLE_NAME);
+ }
+
+ } else { // $values is Message object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(MessagePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the message table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(MessagePeer::TABLE_NAME, $con, MessagePeer::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
+ // instances get re-added by the select statement contained therein).
+ MessagePeer::clearInstancePool();
+ MessagePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Message or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Message object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ MessagePeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Message) { // it's a model object
+ // invalidate the cache for this single object
+ MessagePeer::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(MessagePeer::DATABASE_NAME);
+ $criteria->add(MessagePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ MessagePeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(MessagePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ MessagePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Message object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Message $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(MessagePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(MessagePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(MessagePeer::DATABASE_NAME, MessagePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Message
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = MessagePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(MessagePeer::DATABASE_NAME);
+ $criteria->add(MessagePeer::ID, $pk);
+
+ $v = MessagePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Message[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(MessagePeer::DATABASE_NAME);
+ $criteria->add(MessagePeer::ID, $pks, Criteria::IN);
+ $objs = MessagePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseMessagePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseMessagePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseMessageQuery.php b/core/lib/Thelia/Model/om/BaseMessageQuery.php
new file mode 100644
index 000000000..03221281b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessageQuery.php
@@ -0,0 +1,510 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Message|Message[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = MessagePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Message A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CODE`, `SECURE`, `CREATED_AT`, `UPDATED_AT` FROM `message` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Message();
+ $obj->hydrate($row);
+ MessagePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Message|Message[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Message[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(MessagePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(MessagePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(MessagePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessagePeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the secure column
+ *
+ * Example usage:
+ *
+ * $query->filterBySecure(1234); // WHERE secure = 1234
+ * $query->filterBySecure(array(12, 34)); // WHERE secure IN (12, 34)
+ * $query->filterBySecure(array('min' => 12)); // WHERE secure > 12
+ *
+ *
+ * @param mixed $secure The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function filterBySecure($secure = null, $comparison = null)
+ {
+ if (is_array($secure)) {
+ $useMinMax = false;
+ if (isset($secure['min'])) {
+ $this->addUsingAlias(MessagePeer::SECURE, $secure['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($secure['max'])) {
+ $this->addUsingAlias(MessagePeer::SECURE, $secure['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessagePeer::SECURE, $secure, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(MessagePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(MessagePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessagePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related MessageDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByMessageDesc($messageDesc, $comparison = null)
+ {
+ if ($messageDesc instanceof MessageDesc) {
+ return $this
+ ->addUsingAlias(MessagePeer::ID, $messageDesc->getMessageId(), $comparison);
+ } elseif ($messageDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useMessageDescQuery()
+ ->filterByPrimaryKeys($messageDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByMessageDesc() only accepts arguments of type MessageDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the MessageDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function joinMessageDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('MessageDesc');
+
+ // 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, 'MessageDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the MessageDesc relation MessageDesc 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\MessageDescQuery A secondary query class using the current class as primary query
+ */
+ public function useMessageDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinMessageDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'MessageDesc', '\Thelia\Model\MessageDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Message $message Object to remove from the list of results
+ *
+ * @return MessageQuery The current query, for fluid interface
+ */
+ public function prune($message = null)
+ {
+ if ($message) {
+ $this->addUsingAlias(MessagePeer::ID, $message->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseModule.php b/core/lib/Thelia/Model/om/BaseModule.php
new file mode 100644
index 000000000..0ba8ad580
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseModule.php
@@ -0,0 +1,1739 @@
+id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [type] column value.
+ *
+ * @return int
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Get the [activate] column value.
+ *
+ * @return int
+ */
+ public function getActivate()
+ {
+ return $this->activate;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Module The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ModulePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return Module The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = ModulePeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [type] column.
+ *
+ * @param int $v new value
+ * @return Module The current object (for fluent API support)
+ */
+ public function setType($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->type !== $v) {
+ $this->type = $v;
+ $this->modifiedColumns[] = ModulePeer::TYPE;
+ }
+
+
+ return $this;
+ } // setType()
+
+ /**
+ * Set the value of [activate] column.
+ *
+ * @param int $v new value
+ * @return Module The current object (for fluent API support)
+ */
+ public function setActivate($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->activate !== $v) {
+ $this->activate = $v;
+ $this->modifiedColumns[] = ModulePeer::ACTIVATE;
+ }
+
+
+ return $this;
+ } // setActivate()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Module The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ModulePeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Module The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ModulePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Module The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ModulePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->type = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->activate = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = ModulePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Module object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ModulePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collGroupModules = null;
+
+ $this->collModuleDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ModuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ModulePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ModulePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ModulePeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(ModulePeer::TYPE)) {
+ $modifiedColumns[':p' . $index++] = '`TYPE`';
+ }
+ if ($this->isColumnModified(ModulePeer::ACTIVATE)) {
+ $modifiedColumns[':p' . $index++] = '`ACTIVATE`';
+ }
+ if ($this->isColumnModified(ModulePeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(ModulePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ModulePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `module` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`TYPE`':
+ $stmt->bindValue($identifier, $this->type, PDO::PARAM_INT);
+ break;
+ case '`ACTIVATE`':
+ $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getType();
+ break;
+ case 3:
+ return $this->getActivate();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Module'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Module'][$this->getPrimaryKey()] = true;
+ $keys = ModulePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getType(),
+ $keys[3] => $this->getActivate(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collGroupModules) {
+ $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collModuleDescs) {
+ $result['ModuleDescs'] = $this->collModuleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setType($value);
+ break;
+ case 3:
+ $this->setActivate($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ModulePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setActivate($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ModulePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ModulePeer::ID)) $criteria->add(ModulePeer::ID, $this->id);
+ if ($this->isColumnModified(ModulePeer::CODE)) $criteria->add(ModulePeer::CODE, $this->code);
+ if ($this->isColumnModified(ModulePeer::TYPE)) $criteria->add(ModulePeer::TYPE, $this->type);
+ if ($this->isColumnModified(ModulePeer::ACTIVATE)) $criteria->add(ModulePeer::ACTIVATE, $this->activate);
+ if ($this->isColumnModified(ModulePeer::POSITION)) $criteria->add(ModulePeer::POSITION, $this->position);
+ if ($this->isColumnModified(ModulePeer::CREATED_AT)) $criteria->add(ModulePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ModulePeer::UPDATED_AT)) $criteria->add(ModulePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ModulePeer::DATABASE_NAME);
+ $criteria->add(ModulePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Module (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setType($this->getType());
+ $copyObj->setActivate($this->getActivate());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getGroupModules() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupModule($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getModuleDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addModuleDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Module Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ModulePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ModulePeer();
+ }
+
+ 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.
+ *
+ * @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 getGroupModules($criteria = null, PropelPDO $con = 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 {
+ return count($this->collGroupModules);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param GroupModule $groupModule The groupModule object to add.
+ */
+ protected function doAddGroupModule($groupModule)
+ {
+ $this->collGroupModules[]= $groupModule;
+ $groupModule->setModule($this);
+ }
+
+ /**
+ * @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.
+ *
+ * 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 getModuleDescs($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collModuleDescsPartial && !$this->isNew();
+ if (null === $this->collModuleDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collModuleDescs) {
+ // return empty collection
+ $this->initModuleDescs();
+ } else {
+ $collModuleDescs = ModuleDescQuery::create(null, $criteria)
+ ->filterByModule($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collModuleDescsPartial && count($collModuleDescs)) {
+ $this->initModuleDescs(false);
+
+ foreach($collModuleDescs as $obj) {
+ if (false == $this->collModuleDescs->contains($obj)) {
+ $this->collModuleDescs->append($obj);
+ }
+ }
+
+ $this->collModuleDescsPartial = true;
+ }
+
+ return $collModuleDescs;
+ }
+
+ if($partial && $this->collModuleDescs) {
+ foreach($this->collModuleDescs as $obj) {
+ if($obj->isNew()) {
+ $collModuleDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collModuleDescs = $collModuleDescs;
+ $this->collModuleDescsPartial = false;
+ }
+ }
+
+ return $this->collModuleDescs;
+ }
+
+ /**
+ * Sets a collection of ModuleDesc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $moduleDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setModuleDescs(PropelCollection $moduleDescs, PropelPDO $con = null)
+ {
+ $this->moduleDescsScheduledForDeletion = $this->getModuleDescs(new Criteria(), $con)->diff($moduleDescs);
+
+ foreach ($this->moduleDescsScheduledForDeletion as $moduleDescRemoved) {
+ $moduleDescRemoved->setModule(null);
+ }
+
+ $this->collModuleDescs = null;
+ foreach ($moduleDescs as $moduleDesc) {
+ $this->addModuleDesc($moduleDesc);
+ }
+
+ $this->collModuleDescs = $moduleDescs;
+ $this->collModuleDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related ModuleDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ModuleDesc objects.
+ * @throws PropelException
+ */
+ public function countModuleDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collModuleDescsPartial && !$this->isNew();
+ if (null === $this->collModuleDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collModuleDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getModuleDescs());
+ }
+ $query = ModuleDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByModule($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collModuleDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a ModuleDesc object to this object
+ * through the ModuleDesc foreign key attribute.
+ *
+ * @param ModuleDesc $l ModuleDesc
+ * @return Module The current object (for fluent API support)
+ */
+ public function addModuleDesc(ModuleDesc $l)
+ {
+ if ($this->collModuleDescs === null) {
+ $this->initModuleDescs();
+ $this->collModuleDescsPartial = true;
+ }
+ if (!$this->collModuleDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddModuleDesc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ModuleDesc $moduleDesc The moduleDesc object to add.
+ */
+ protected function doAddModuleDesc($moduleDesc)
+ {
+ $this->collModuleDescs[]= $moduleDesc;
+ $moduleDesc->setModule($this);
+ }
+
+ /**
+ * @param ModuleDesc $moduleDesc The moduleDesc object to remove.
+ */
+ public function removeModuleDesc($moduleDesc)
+ {
+ if ($this->getModuleDescs()->contains($moduleDesc)) {
+ $this->collModuleDescs->remove($this->collModuleDescs->search($moduleDesc));
+ if (null === $this->moduleDescsScheduledForDeletion) {
+ $this->moduleDescsScheduledForDeletion = clone $this->collModuleDescs;
+ $this->moduleDescsScheduledForDeletion->clear();
+ }
+ $this->moduleDescsScheduledForDeletion[]= $moduleDesc;
+ $moduleDesc->setModule(null);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->type = null;
+ $this->activate = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ if ($this->collGroupModules instanceof PropelCollection) {
+ $this->collGroupModules->clearIterator();
+ }
+ $this->collGroupModules = null;
+ if ($this->collModuleDescs instanceof PropelCollection) {
+ $this->collModuleDescs->clearIterator();
+ }
+ $this->collModuleDescs = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ModulePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseModuleDesc.php b/core/lib/Thelia/Model/om/BaseModuleDesc.php
new file mode 100644
index 000000000..476dbc2b3
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseModuleDesc.php
@@ -0,0 +1,1375 @@
+id;
+ }
+
+ /**
+ * Get the [module_id] column value.
+ *
+ * @return int
+ */
+ public function getModuleId()
+ {
+ return $this->module_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [currency_id] column value.
+ *
+ * @return int
+ */
+ public function getCurrencyId()
+ {
+ return $this->currency_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ModuleDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [module_id] column.
+ *
+ * @param int $v new value
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setModuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->module_id !== $v) {
+ $this->module_id = $v;
+ $this->modifiedColumns[] = ModuleDescPeer::MODULE_ID;
+ }
+
+ if ($this->aModule !== null && $this->aModule->getId() !== $v) {
+ $this->aModule = null;
+ }
+
+
+ return $this;
+ } // setModuleId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = ModuleDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ModuleDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ModuleDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ModuleDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [currency_id] column.
+ *
+ * @param int $v new value
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setCurrencyId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->currency_id !== $v) {
+ $this->currency_id = $v;
+ $this->modifiedColumns[] = ModuleDescPeer::CURRENCY_ID;
+ }
+
+
+ return $this;
+ } // setCurrencyId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ModuleDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ModuleDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ModuleDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->module_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->currency_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
+ $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = ModuleDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ModuleDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) {
+ $this->aModule = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ModuleDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aModule = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ModuleDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ModuleDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ModuleDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ModuleDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ModuleDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ModuleDescPeer::MODULE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`MODULE_ID`';
+ }
+ if ($this->isColumnModified(ModuleDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(ModuleDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(ModuleDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(ModuleDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(ModuleDescPeer::CURRENCY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CURRENCY_ID`';
+ }
+ if ($this->isColumnModified(ModuleDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ModuleDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `module_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`MODULE_ID`':
+ $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CURRENCY_ID`':
+ $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ModuleDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getModuleId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCurrencyId();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ModuleDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ModuleDesc'][$this->getPrimaryKey()] = true;
+ $keys = ModuleDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getModuleId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCurrencyId(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aModule) {
+ $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ModuleDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setModuleId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCurrencyId($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ModuleDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setModuleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCurrencyId($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ModuleDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ModuleDescPeer::ID)) $criteria->add(ModuleDescPeer::ID, $this->id);
+ if ($this->isColumnModified(ModuleDescPeer::MODULE_ID)) $criteria->add(ModuleDescPeer::MODULE_ID, $this->module_id);
+ if ($this->isColumnModified(ModuleDescPeer::LANG)) $criteria->add(ModuleDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(ModuleDescPeer::TITLE)) $criteria->add(ModuleDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(ModuleDescPeer::DESCRIPTION)) $criteria->add(ModuleDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ModuleDescPeer::CHAPO)) $criteria->add(ModuleDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ModuleDescPeer::CURRENCY_ID)) $criteria->add(ModuleDescPeer::CURRENCY_ID, $this->currency_id);
+ if ($this->isColumnModified(ModuleDescPeer::CREATED_AT)) $criteria->add(ModuleDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ModuleDescPeer::UPDATED_AT)) $criteria->add(ModuleDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ModuleDescPeer::DATABASE_NAME);
+ $criteria->add(ModuleDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ModuleDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setModuleId($this->getModuleId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCurrencyId($this->getCurrencyId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ModuleDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ModuleDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ModuleDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Module object.
+ *
+ * @param Module $v
+ * @return ModuleDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setModule(Module $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->module_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->currency_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aModule = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ModuleDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseModuleDescPeer.php b/core/lib/Thelia/Model/om/BaseModuleDescPeer.php
new file mode 100644
index 000000000..c6c1dbb3e
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseModuleDescPeer.php
@@ -0,0 +1,1042 @@
+ array ('Id', 'ModuleId', 'Lang', 'Title', 'Description', 'Chapo', 'CurrencyId', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'moduleId', 'lang', 'title', 'description', 'chapo', 'currencyId', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ModuleDescPeer::ID, ModuleDescPeer::MODULE_ID, ModuleDescPeer::LANG, ModuleDescPeer::TITLE, ModuleDescPeer::DESCRIPTION, ModuleDescPeer::CHAPO, ModuleDescPeer::CURRENCY_ID, ModuleDescPeer::CREATED_AT, ModuleDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'MODULE_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CURRENCY_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'module_id', 'lang', 'title', 'description', 'chapo', 'currency_id', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ModuleDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ModuleId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CurrencyId' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'moduleId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'currencyId' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ BasePeer::TYPE_COLNAME => array (ModuleDescPeer::ID => 0, ModuleDescPeer::MODULE_ID => 1, ModuleDescPeer::LANG => 2, ModuleDescPeer::TITLE => 3, ModuleDescPeer::DESCRIPTION => 4, ModuleDescPeer::CHAPO => 5, ModuleDescPeer::CURRENCY_ID => 6, ModuleDescPeer::CREATED_AT => 7, ModuleDescPeer::UPDATED_AT => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'MODULE_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CURRENCY_ID' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'module_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'currency_id' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ModuleDescPeer::getFieldNames($toType);
+ $key = isset(ModuleDescPeer::$fieldKeys[$fromType][$name]) ? ModuleDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ModuleDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ModuleDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ModuleDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ModuleDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ModuleDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ModuleDescPeer::ID);
+ $criteria->addSelectColumn(ModuleDescPeer::MODULE_ID);
+ $criteria->addSelectColumn(ModuleDescPeer::LANG);
+ $criteria->addSelectColumn(ModuleDescPeer::TITLE);
+ $criteria->addSelectColumn(ModuleDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(ModuleDescPeer::CHAPO);
+ $criteria->addSelectColumn(ModuleDescPeer::CURRENCY_ID);
+ $criteria->addSelectColumn(ModuleDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(ModuleDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.MODULE_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CURRENCY_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ModuleDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ModuleDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ModuleDescPeer::populateObjects(ModuleDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ModuleDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ModuleDesc $obj A ModuleDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ModuleDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ModuleDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ModuleDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ModuleDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ModuleDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ModuleDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ModuleDescPeer::$instances[$key])) {
+ return ModuleDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ModuleDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to module_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ModuleDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ModuleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ModuleDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ModuleDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ModuleDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ModuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ModuleDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ModuleDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ModuleDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ModuleDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ModuleDescPeer::DATABASE_NAME)->getTable(ModuleDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseModuleDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseModuleDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ModuleDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ModuleDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ModuleDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ModuleDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ModuleDesc object
+ }
+
+ if ($criteria->containsKey(ModuleDescPeer::ID) && $criteria->keyContainsValue(ModuleDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ModuleDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ModuleDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ModuleDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ModuleDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ModuleDescPeer::ID);
+ $value = $criteria->remove(ModuleDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ModuleDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ModuleDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ModuleDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the module_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ModuleDescPeer::clearInstancePool();
+ ModuleDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ModuleDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ModuleDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ModuleDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ModuleDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ModuleDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ModuleDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ModuleDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ModuleDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ModuleDescPeer::DATABASE_NAME, ModuleDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return ModuleDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ModuleDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ModuleDescPeer::DATABASE_NAME);
+ $criteria->add(ModuleDescPeer::ID, $pk);
+
+ $v = ModuleDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return ModuleDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ModuleDescPeer::DATABASE_NAME);
+ $criteria->add(ModuleDescPeer::ID, $pks, Criteria::IN);
+ $objs = ModuleDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseModuleDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseModuleDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseModuleDescQuery.php b/core/lib/Thelia/Model/om/BaseModuleDescQuery.php
new file mode 100644
index 000000000..8d477930c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseModuleDescQuery.php
@@ -0,0 +1,658 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ModuleDesc|ModuleDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ModuleDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ModuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ModuleDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `MODULE_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CURRENCY_ID`, `CREATED_AT`, `UPDATED_AT` FROM `module_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ModuleDesc();
+ $obj->hydrate($row);
+ ModuleDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ModuleDesc|ModuleDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ModuleDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ModuleDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ModuleDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the module_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByModuleId(1234); // WHERE module_id = 1234
+ * $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34)
+ * $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
+ *
+ *
+ * @see filterByModule()
+ *
+ * @param mixed $moduleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByModuleId($moduleId = null, $comparison = null)
+ {
+ if (is_array($moduleId)) {
+ $useMinMax = false;
+ if (isset($moduleId['min'])) {
+ $this->addUsingAlias(ModuleDescPeer::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($moduleId['max'])) {
+ $this->addUsingAlias(ModuleDescPeer::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::MODULE_ID, $moduleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyId(1234); // WHERE currency_id = 1234
+ * $query->filterByCurrencyId(array(12, 34)); // WHERE currency_id IN (12, 34)
+ * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id > 12
+ *
+ *
+ * @param mixed $currencyId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyId($currencyId = null, $comparison = null)
+ {
+ if (is_array($currencyId)) {
+ $useMinMax = false;
+ if (isset($currencyId['min'])) {
+ $this->addUsingAlias(ModuleDescPeer::CURRENCY_ID, $currencyId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyId['max'])) {
+ $this->addUsingAlias(ModuleDescPeer::CURRENCY_ID, $currencyId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::CURRENCY_ID, $currencyId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ModuleDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ModuleDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ModuleDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ModuleDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Module object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByModule($module, $comparison = null)
+ {
+ if ($module instanceof Module) {
+ return $this
+ ->addUsingAlias(ModuleDescPeer::MODULE_ID, $module->getId(), $comparison);
+ } elseif ($module instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ModuleDescPeer::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByModule() only accepts arguments of type Module or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Module relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Module');
+
+ // 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, 'Module');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Module relation Module 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\ModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ModuleDesc $moduleDesc Object to remove from the list of results
+ *
+ * @return ModuleDescQuery The current query, for fluid interface
+ */
+ public function prune($moduleDesc = null)
+ {
+ if ($moduleDesc) {
+ $this->addUsingAlias(ModuleDescPeer::ID, $moduleDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseModulePeer.php b/core/lib/Thelia/Model/om/BaseModulePeer.php
new file mode 100644
index 000000000..6a4ce8b36
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseModulePeer.php
@@ -0,0 +1,797 @@
+ array ('Id', 'Code', 'Type', 'Activate', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'type', 'activate', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ModulePeer::ID, ModulePeer::CODE, ModulePeer::TYPE, ModulePeer::ACTIVATE, ModulePeer::POSITION, ModulePeer::CREATED_AT, ModulePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'TYPE', 'ACTIVATE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'type', 'activate', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ModulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Type' => 2, 'Activate' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (ModulePeer::ID => 0, ModulePeer::CODE => 1, ModulePeer::TYPE => 2, ModulePeer::ACTIVATE => 3, ModulePeer::POSITION => 4, ModulePeer::CREATED_AT => 5, ModulePeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'ACTIVATE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ModulePeer::getFieldNames($toType);
+ $key = isset(ModulePeer::$fieldKeys[$fromType][$name]) ? ModulePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ModulePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ModulePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ModulePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ModulePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ModulePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ModulePeer::ID);
+ $criteria->addSelectColumn(ModulePeer::CODE);
+ $criteria->addSelectColumn(ModulePeer::TYPE);
+ $criteria->addSelectColumn(ModulePeer::ACTIVATE);
+ $criteria->addSelectColumn(ModulePeer::POSITION);
+ $criteria->addSelectColumn(ModulePeer::CREATED_AT);
+ $criteria->addSelectColumn(ModulePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.TYPE');
+ $criteria->addSelectColumn($alias . '.ACTIVATE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ModulePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Module
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ModulePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ModulePeer::populateObjects(ModulePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ModulePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ModulePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Module $obj A Module object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ModulePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Module object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Module) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Module object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ModulePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Module Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ModulePeer::$instances[$key])) {
+ return ModulePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ModulePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to module
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ModulePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ModulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ModulePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ModulePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Module object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ModulePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ModulePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ModulePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ModulePeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ModulePeer::DATABASE_NAME)->getTable(ModulePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseModulePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseModulePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ModuleTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ModulePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Module or Criteria object.
+ *
+ * @param mixed $values Criteria or Module object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Module object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ModulePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Module or Criteria object.
+ *
+ * @param mixed $values Criteria or Module object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ModulePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ModulePeer::ID);
+ $value = $criteria->remove(ModulePeer::ID);
+ if ($value) {
+ $selectCriteria->add(ModulePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ModulePeer::TABLE_NAME);
+ }
+
+ } else { // $values is Module object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ModulePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the module table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(ModulePeer::TABLE_NAME, $con, ModulePeer::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
+ // instances get re-added by the select statement contained therein).
+ ModulePeer::clearInstancePool();
+ ModulePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Module or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Module object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ ModulePeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Module) { // it's a model object
+ // invalidate the cache for this single object
+ ModulePeer::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(ModulePeer::DATABASE_NAME);
+ $criteria->add(ModulePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ModulePeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ModulePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ModulePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Module object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Module $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ModulePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ModulePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ModulePeer::DATABASE_NAME, ModulePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Module
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ModulePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ModulePeer::DATABASE_NAME);
+ $criteria->add(ModulePeer::ID, $pk);
+
+ $v = ModulePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Module[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ModulePeer::DATABASE_NAME);
+ $criteria->add(ModulePeer::ID, $pks, Criteria::IN);
+ $objs = ModulePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseModulePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseModulePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseModuleQuery.php b/core/lib/Thelia/Model/om/BaseModuleQuery.php
new file mode 100644
index 000000000..66d427021
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseModuleQuery.php
@@ -0,0 +1,679 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Module|Module[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ModulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Module A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CODE`, `TYPE`, `ACTIVATE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `module` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Module();
+ $obj->hydrate($row);
+ ModulePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Module|Module[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Module[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ModulePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ModulePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ModulePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModulePeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the type column
+ *
+ * Example usage:
+ *
+ * $query->filterByType(1234); // WHERE type = 1234
+ * $query->filterByType(array(12, 34)); // WHERE type IN (12, 34)
+ * $query->filterByType(array('min' => 12)); // WHERE type > 12
+ *
+ *
+ * @param mixed $type The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterByType($type = null, $comparison = null)
+ {
+ if (is_array($type)) {
+ $useMinMax = false;
+ if (isset($type['min'])) {
+ $this->addUsingAlias(ModulePeer::TYPE, $type['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($type['max'])) {
+ $this->addUsingAlias(ModulePeer::TYPE, $type['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModulePeer::TYPE, $type, $comparison);
+ }
+
+ /**
+ * Filter the query on the activate column
+ *
+ * Example usage:
+ *
+ * $query->filterByActivate(1234); // WHERE activate = 1234
+ * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34)
+ * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12
+ *
+ *
+ * @param mixed $activate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterByActivate($activate = null, $comparison = null)
+ {
+ if (is_array($activate)) {
+ $useMinMax = false;
+ if (isset($activate['min'])) {
+ $this->addUsingAlias(ModulePeer::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($activate['max'])) {
+ $this->addUsingAlias(ModulePeer::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModulePeer::ACTIVATE, $activate, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ModulePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ModulePeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModulePeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ModulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ModulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModulePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related GroupModule object
+ *
+ * @param GroupModule|PropelObjectCollection $groupModule the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroupModule($groupModule, $comparison = null)
+ {
+ if ($groupModule instanceof GroupModule) {
+ return $this
+ ->addUsingAlias(ModulePeer::ID, $groupModule->getModuleId(), $comparison);
+ } elseif ($groupModule instanceof PropelObjectCollection) {
+ return $this
+ ->useGroupModuleQuery()
+ ->filterByPrimaryKeys($groupModule->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupModule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function joinGroupModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupModule');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupModule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupModule relation GroupModule object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinGroupModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery');
+ }
+
+ /**
+ * Filter the query by a related ModuleDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByModuleDesc($moduleDesc, $comparison = null)
+ {
+ if ($moduleDesc instanceof ModuleDesc) {
+ return $this
+ ->addUsingAlias(ModulePeer::ID, $moduleDesc->getModuleId(), $comparison);
+ } elseif ($moduleDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useModuleDescQuery()
+ ->filterByPrimaryKeys($moduleDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByModuleDesc() only accepts arguments of type ModuleDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ModuleDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function joinModuleDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ModuleDesc');
+
+ // 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, 'ModuleDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ModuleDesc relation ModuleDesc 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\ModuleDescQuery A secondary query class using the current class as primary query
+ */
+ public function useModuleDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinModuleDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ModuleDesc', '\Thelia\Model\ModuleDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Module $module Object to remove from the list of results
+ *
+ * @return ModuleQuery The current query, for fluid interface
+ */
+ public function prune($module = null)
+ {
+ if ($module) {
+ $this->addUsingAlias(ModulePeer::ID, $module->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrder.php b/core/lib/Thelia/Model/om/BaseOrder.php
new file mode 100644
index 000000000..199a7f43d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrder.php
@@ -0,0 +1,2782 @@
+id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+ return $this->ref;
+ }
+
+ /**
+ * Get the [customer_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerId()
+ {
+ return $this->customer_id;
+ }
+
+ /**
+ * Get the [address_invoice] column value.
+ *
+ * @return int
+ */
+ public function getAddressInvoice()
+ {
+ return $this->address_invoice;
+ }
+
+ /**
+ * Get the [address_delivery] column value.
+ *
+ * @return int
+ */
+ public function getAddressDelivery()
+ {
+ return $this->address_delivery;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [invoice_date] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getInvoiceDate($format = '%x')
+ {
+ if ($this->invoice_date === null) {
+ return null;
+ }
+
+ if ($this->invoice_date === '0000-00-00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->invoice_date);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->invoice_date, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [currency_id] column value.
+ *
+ * @return int
+ */
+ public function getCurrencyId()
+ {
+ return $this->currency_id;
+ }
+
+ /**
+ * Get the [currency_rate] column value.
+ *
+ * @return double
+ */
+ public function getCurrencyRate()
+ {
+ return $this->currency_rate;
+ }
+
+ /**
+ * Get the [transaction] column value.
+ *
+ * @return string
+ */
+ public function getTransaction()
+ {
+ return $this->transaction;
+ }
+
+ /**
+ * Get the [delivery_num] column value.
+ *
+ * @return string
+ */
+ public function getDeliveryNum()
+ {
+ return $this->delivery_num;
+ }
+
+ /**
+ * Get the [invoice] column value.
+ *
+ * @return string
+ */
+ public function getInvoice()
+ {
+ return $this->invoice;
+ }
+
+ /**
+ * Get the [postage] column value.
+ *
+ * @return double
+ */
+ public function getPostage()
+ {
+ return $this->postage;
+ }
+
+ /**
+ * Get the [payment] column value.
+ *
+ * @return string
+ */
+ public function getPayment()
+ {
+ return $this->payment;
+ }
+
+ /**
+ * Get the [carrier] column value.
+ *
+ * @return string
+ */
+ public function getCarrier()
+ {
+ return $this->carrier;
+ }
+
+ /**
+ * Get the [status_id] column value.
+ *
+ * @return int
+ */
+ public function getStatusId()
+ {
+ return $this->status_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = OrderPeer::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [customer_id] column.
+ *
+ * @param int $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setCustomerId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_id !== $v) {
+ $this->customer_id = $v;
+ $this->modifiedColumns[] = OrderPeer::CUSTOMER_ID;
+ }
+
+ if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
+ $this->aCustomer = null;
+ }
+
+
+ return $this;
+ } // setCustomerId()
+
+ /**
+ * Set the value of [address_invoice] column.
+ *
+ * @param int $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setAddressInvoice($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->address_invoice !== $v) {
+ $this->address_invoice = $v;
+ $this->modifiedColumns[] = OrderPeer::ADDRESS_INVOICE;
+ }
+
+ if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->aOrderAddressRelatedByAddressInvoice->getId() !== $v) {
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ }
+
+
+ return $this;
+ } // setAddressInvoice()
+
+ /**
+ * Set the value of [address_delivery] column.
+ *
+ * @param int $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setAddressDelivery($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->address_delivery !== $v) {
+ $this->address_delivery = $v;
+ $this->modifiedColumns[] = OrderPeer::ADDRESS_DELIVERY;
+ }
+
+ if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->aOrderAddressRelatedByAddressDelivery->getId() !== $v) {
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ }
+
+
+ return $this;
+ } // setAddressDelivery()
+
+ /**
+ * Sets the value of [invoice_date] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Order The current object (for fluent API support)
+ */
+ public function setInvoiceDate($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->invoice_date !== null || $dt !== null) {
+ $currentDateAsString = ($this->invoice_date !== null && $tmpDt = new DateTime($this->invoice_date)) ? $tmpDt->format('Y-m-d') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->invoice_date = $newDateAsString;
+ $this->modifiedColumns[] = OrderPeer::INVOICE_DATE;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setInvoiceDate()
+
+ /**
+ * Set the value of [currency_id] column.
+ *
+ * @param int $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setCurrencyId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->currency_id !== $v) {
+ $this->currency_id = $v;
+ $this->modifiedColumns[] = OrderPeer::CURRENCY_ID;
+ }
+
+ if ($this->aCurrency !== null && $this->aCurrency->getId() !== $v) {
+ $this->aCurrency = null;
+ }
+
+
+ return $this;
+ } // setCurrencyId()
+
+ /**
+ * Set the value of [currency_rate] column.
+ *
+ * @param double $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setCurrencyRate($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->currency_rate !== $v) {
+ $this->currency_rate = $v;
+ $this->modifiedColumns[] = OrderPeer::CURRENCY_RATE;
+ }
+
+
+ return $this;
+ } // setCurrencyRate()
+
+ /**
+ * Set the value of [transaction] column.
+ *
+ * @param string $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setTransaction($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->transaction !== $v) {
+ $this->transaction = $v;
+ $this->modifiedColumns[] = OrderPeer::TRANSACTION;
+ }
+
+
+ return $this;
+ } // setTransaction()
+
+ /**
+ * Set the value of [delivery_num] column.
+ *
+ * @param string $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setDeliveryNum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->delivery_num !== $v) {
+ $this->delivery_num = $v;
+ $this->modifiedColumns[] = OrderPeer::DELIVERY_NUM;
+ }
+
+
+ return $this;
+ } // setDeliveryNum()
+
+ /**
+ * Set the value of [invoice] column.
+ *
+ * @param string $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setInvoice($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->invoice !== $v) {
+ $this->invoice = $v;
+ $this->modifiedColumns[] = OrderPeer::INVOICE;
+ }
+
+
+ return $this;
+ } // setInvoice()
+
+ /**
+ * Set the value of [postage] column.
+ *
+ * @param double $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setPostage($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->postage !== $v) {
+ $this->postage = $v;
+ $this->modifiedColumns[] = OrderPeer::POSTAGE;
+ }
+
+
+ return $this;
+ } // setPostage()
+
+ /**
+ * Set the value of [payment] column.
+ *
+ * @param string $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setPayment($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->payment !== $v) {
+ $this->payment = $v;
+ $this->modifiedColumns[] = OrderPeer::PAYMENT;
+ }
+
+
+ return $this;
+ } // setPayment()
+
+ /**
+ * Set the value of [carrier] column.
+ *
+ * @param string $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setCarrier($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->carrier !== $v) {
+ $this->carrier = $v;
+ $this->modifiedColumns[] = OrderPeer::CARRIER;
+ }
+
+
+ return $this;
+ } // setCarrier()
+
+ /**
+ * Set the value of [status_id] column.
+ *
+ * @param int $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setStatusId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->status_id !== $v) {
+ $this->status_id = $v;
+ $this->modifiedColumns[] = OrderPeer::STATUS_ID;
+ }
+
+ if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) {
+ $this->aOrderStatus = null;
+ }
+
+
+ return $this;
+ } // setStatusId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return Order The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = OrderPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Order The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Order The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->ref = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->customer_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->address_invoice = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->address_delivery = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->invoice_date = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->currency_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
+ $this->currency_rate = ($row[$startcol + 7] !== null) ? (double) $row[$startcol + 7] : null;
+ $this->transaction = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->delivery_num = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
+ $this->invoice = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
+ $this->postage = ($row[$startcol + 11] !== null) ? (double) $row[$startcol + 11] : null;
+ $this->payment = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
+ $this->carrier = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
+ $this->status_id = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null;
+ $this->lang = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
+ $this->created_at = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
+ $this->updated_at = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 18; // 18 = OrderPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Order object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
+ $this->aCustomer = 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = OrderPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCurrency = null;
+ $this->aCustomer = null;
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ $this->aOrderStatus = null;
+ $this->collCouponOrders = null;
+
+ $this->collOrderProducts = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = OrderQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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->aCurrency !== null) {
+ if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) {
+ $affectedRows += $this->aCurrency->save($con);
+ }
+ $this->setCurrency($this->aCurrency);
+ }
+
+ if ($this->aCustomer !== null) {
+ if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) {
+ $affectedRows += $this->aCustomer->save($con);
+ }
+ $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()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->couponOrdersScheduledForDeletion !== null) {
+ if (!$this->couponOrdersScheduledForDeletion->isEmpty()) {
+ CouponOrderQuery::create()
+ ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->couponOrdersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCouponOrders !== null) {
+ foreach ($this->collCouponOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->orderProductsScheduledForDeletion !== null) {
+ if (!$this->orderProductsScheduledForDeletion->isEmpty()) {
+ OrderProductQuery::create()
+ ->filterByPrimaryKeys($this->orderProductsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderProductsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderProducts !== null) {
+ foreach ($this->collOrderProducts as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(OrderPeer::REF)) {
+ $modifiedColumns[':p' . $index++] = '`REF`';
+ }
+ if ($this->isColumnModified(OrderPeer::CUSTOMER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CUSTOMER_ID`';
+ }
+ if ($this->isColumnModified(OrderPeer::ADDRESS_INVOICE)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS_INVOICE`';
+ }
+ if ($this->isColumnModified(OrderPeer::ADDRESS_DELIVERY)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS_DELIVERY`';
+ }
+ if ($this->isColumnModified(OrderPeer::INVOICE_DATE)) {
+ $modifiedColumns[':p' . $index++] = '`INVOICE_DATE`';
+ }
+ if ($this->isColumnModified(OrderPeer::CURRENCY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CURRENCY_ID`';
+ }
+ if ($this->isColumnModified(OrderPeer::CURRENCY_RATE)) {
+ $modifiedColumns[':p' . $index++] = '`CURRENCY_RATE`';
+ }
+ if ($this->isColumnModified(OrderPeer::TRANSACTION)) {
+ $modifiedColumns[':p' . $index++] = '`TRANSACTION`';
+ }
+ if ($this->isColumnModified(OrderPeer::DELIVERY_NUM)) {
+ $modifiedColumns[':p' . $index++] = '`DELIVERY_NUM`';
+ }
+ if ($this->isColumnModified(OrderPeer::INVOICE)) {
+ $modifiedColumns[':p' . $index++] = '`INVOICE`';
+ }
+ if ($this->isColumnModified(OrderPeer::POSTAGE)) {
+ $modifiedColumns[':p' . $index++] = '`POSTAGE`';
+ }
+ if ($this->isColumnModified(OrderPeer::PAYMENT)) {
+ $modifiedColumns[':p' . $index++] = '`PAYMENT`';
+ }
+ if ($this->isColumnModified(OrderPeer::CARRIER)) {
+ $modifiedColumns[':p' . $index++] = '`CARRIER`';
+ }
+ if ($this->isColumnModified(OrderPeer::STATUS_ID)) {
+ $modifiedColumns[':p' . $index++] = '`STATUS_ID`';
+ }
+ if ($this->isColumnModified(OrderPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(OrderPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(OrderPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `order` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`REF`':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case '`CUSTOMER_ID`':
+ $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
+ break;
+ case '`ADDRESS_INVOICE`':
+ $stmt->bindValue($identifier, $this->address_invoice, PDO::PARAM_INT);
+ break;
+ case '`ADDRESS_DELIVERY`':
+ $stmt->bindValue($identifier, $this->address_delivery, PDO::PARAM_INT);
+ break;
+ case '`INVOICE_DATE`':
+ $stmt->bindValue($identifier, $this->invoice_date, PDO::PARAM_STR);
+ break;
+ case '`CURRENCY_ID`':
+ $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT);
+ break;
+ case '`CURRENCY_RATE`':
+ $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR);
+ break;
+ case '`TRANSACTION`':
+ $stmt->bindValue($identifier, $this->transaction, PDO::PARAM_STR);
+ break;
+ case '`DELIVERY_NUM`':
+ $stmt->bindValue($identifier, $this->delivery_num, PDO::PARAM_STR);
+ break;
+ case '`INVOICE`':
+ $stmt->bindValue($identifier, $this->invoice, PDO::PARAM_STR);
+ break;
+ case '`POSTAGE`':
+ $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR);
+ break;
+ case '`PAYMENT`':
+ $stmt->bindValue($identifier, $this->payment, PDO::PARAM_STR);
+ break;
+ case '`CARRIER`':
+ $stmt->bindValue($identifier, $this->carrier, PDO::PARAM_STR);
+ break;
+ case '`STATUS_ID`':
+ $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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->aCurrency !== null) {
+ if (!$this->aCurrency->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCurrency->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());
+ }
+ }
+
+
+ if (($retval = OrderPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ if ($this->collCouponOrders !== null) {
+ foreach ($this->collCouponOrders as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+ if ($this->collOrderProducts !== null) {
+ foreach ($this->collOrderProducts as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getRef();
+ break;
+ case 2:
+ return $this->getCustomerId();
+ break;
+ case 3:
+ return $this->getAddressInvoice();
+ break;
+ case 4:
+ return $this->getAddressDelivery();
+ break;
+ case 5:
+ return $this->getInvoiceDate();
+ break;
+ case 6:
+ return $this->getCurrencyId();
+ break;
+ case 7:
+ return $this->getCurrencyRate();
+ break;
+ case 8:
+ return $this->getTransaction();
+ break;
+ case 9:
+ return $this->getDeliveryNum();
+ break;
+ case 10:
+ return $this->getInvoice();
+ break;
+ case 11:
+ return $this->getPostage();
+ break;
+ case 12:
+ return $this->getPayment();
+ break;
+ case 13:
+ return $this->getCarrier();
+ break;
+ case 14:
+ return $this->getStatusId();
+ break;
+ case 15:
+ return $this->getLang();
+ break;
+ case 16:
+ return $this->getCreatedAt();
+ break;
+ case 17:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Order'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Order'][$this->getPrimaryKey()] = true;
+ $keys = OrderPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRef(),
+ $keys[2] => $this->getCustomerId(),
+ $keys[3] => $this->getAddressInvoice(),
+ $keys[4] => $this->getAddressDelivery(),
+ $keys[5] => $this->getInvoiceDate(),
+ $keys[6] => $this->getCurrencyId(),
+ $keys[7] => $this->getCurrencyRate(),
+ $keys[8] => $this->getTransaction(),
+ $keys[9] => $this->getDeliveryNum(),
+ $keys[10] => $this->getInvoice(),
+ $keys[11] => $this->getPostage(),
+ $keys[12] => $this->getPayment(),
+ $keys[13] => $this->getCarrier(),
+ $keys[14] => $this->getStatusId(),
+ $keys[15] => $this->getLang(),
+ $keys[16] => $this->getCreatedAt(),
+ $keys[17] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCurrency) {
+ $result['Currency'] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCustomer) {
+ $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aOrderAddressRelatedByAddressInvoice) {
+ $result['OrderAddressRelatedByAddressInvoice'] = $this->aOrderAddressRelatedByAddressInvoice->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aOrderAddressRelatedByAddressDelivery) {
+ $result['OrderAddressRelatedByAddressDelivery'] = $this->aOrderAddressRelatedByAddressDelivery->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aOrderStatus) {
+ $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collCouponOrders) {
+ $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrderProducts) {
+ $result['OrderProducts'] = $this->collOrderProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setRef($value);
+ break;
+ case 2:
+ $this->setCustomerId($value);
+ break;
+ case 3:
+ $this->setAddressInvoice($value);
+ break;
+ case 4:
+ $this->setAddressDelivery($value);
+ break;
+ case 5:
+ $this->setInvoiceDate($value);
+ break;
+ case 6:
+ $this->setCurrencyId($value);
+ break;
+ case 7:
+ $this->setCurrencyRate($value);
+ break;
+ case 8:
+ $this->setTransaction($value);
+ break;
+ case 9:
+ $this->setDeliveryNum($value);
+ break;
+ case 10:
+ $this->setInvoice($value);
+ break;
+ case 11:
+ $this->setPostage($value);
+ break;
+ case 12:
+ $this->setPayment($value);
+ break;
+ case 13:
+ $this->setCarrier($value);
+ break;
+ case 14:
+ $this->setStatusId($value);
+ break;
+ case 15:
+ $this->setLang($value);
+ break;
+ case 16:
+ $this->setCreatedAt($value);
+ break;
+ case 17:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = OrderPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setAddressInvoice($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setAddressDelivery($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setInvoiceDate($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCurrencyId($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCurrencyRate($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setTransaction($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setDeliveryNum($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setInvoice($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setPostage($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setPayment($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setCarrier($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setStatusId($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setLang($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]);
+ if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderPeer::ID)) $criteria->add(OrderPeer::ID, $this->id);
+ if ($this->isColumnModified(OrderPeer::REF)) $criteria->add(OrderPeer::REF, $this->ref);
+ if ($this->isColumnModified(OrderPeer::CUSTOMER_ID)) $criteria->add(OrderPeer::CUSTOMER_ID, $this->customer_id);
+ if ($this->isColumnModified(OrderPeer::ADDRESS_INVOICE)) $criteria->add(OrderPeer::ADDRESS_INVOICE, $this->address_invoice);
+ if ($this->isColumnModified(OrderPeer::ADDRESS_DELIVERY)) $criteria->add(OrderPeer::ADDRESS_DELIVERY, $this->address_delivery);
+ if ($this->isColumnModified(OrderPeer::INVOICE_DATE)) $criteria->add(OrderPeer::INVOICE_DATE, $this->invoice_date);
+ if ($this->isColumnModified(OrderPeer::CURRENCY_ID)) $criteria->add(OrderPeer::CURRENCY_ID, $this->currency_id);
+ if ($this->isColumnModified(OrderPeer::CURRENCY_RATE)) $criteria->add(OrderPeer::CURRENCY_RATE, $this->currency_rate);
+ if ($this->isColumnModified(OrderPeer::TRANSACTION)) $criteria->add(OrderPeer::TRANSACTION, $this->transaction);
+ if ($this->isColumnModified(OrderPeer::DELIVERY_NUM)) $criteria->add(OrderPeer::DELIVERY_NUM, $this->delivery_num);
+ if ($this->isColumnModified(OrderPeer::INVOICE)) $criteria->add(OrderPeer::INVOICE, $this->invoice);
+ if ($this->isColumnModified(OrderPeer::POSTAGE)) $criteria->add(OrderPeer::POSTAGE, $this->postage);
+ if ($this->isColumnModified(OrderPeer::PAYMENT)) $criteria->add(OrderPeer::PAYMENT, $this->payment);
+ if ($this->isColumnModified(OrderPeer::CARRIER)) $criteria->add(OrderPeer::CARRIER, $this->carrier);
+ if ($this->isColumnModified(OrderPeer::STATUS_ID)) $criteria->add(OrderPeer::STATUS_ID, $this->status_id);
+ if ($this->isColumnModified(OrderPeer::LANG)) $criteria->add(OrderPeer::LANG, $this->lang);
+ if ($this->isColumnModified(OrderPeer::CREATED_AT)) $criteria->add(OrderPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderPeer::UPDATED_AT)) $criteria->add(OrderPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderPeer::DATABASE_NAME);
+ $criteria->add(OrderPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Order (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCustomerId($this->getCustomerId());
+ $copyObj->setAddressInvoice($this->getAddressInvoice());
+ $copyObj->setAddressDelivery($this->getAddressDelivery());
+ $copyObj->setInvoiceDate($this->getInvoiceDate());
+ $copyObj->setCurrencyId($this->getCurrencyId());
+ $copyObj->setCurrencyRate($this->getCurrencyRate());
+ $copyObj->setTransaction($this->getTransaction());
+ $copyObj->setDeliveryNum($this->getDeliveryNum());
+ $copyObj->setInvoice($this->getInvoice());
+ $copyObj->setPostage($this->getPostage());
+ $copyObj->setPayment($this->getPayment());
+ $copyObj->setCarrier($this->getCarrier());
+ $copyObj->setStatusId($this->getStatusId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getCouponOrders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCouponOrder($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getOrderProducts() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderProduct($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Order Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return OrderPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new OrderPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Currency object.
+ *
+ * @param Currency $v
+ * @return Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCurrency(Currency $v = null)
+ {
+ if ($v === null) {
+ $this->setCurrencyId(NULL);
+ } else {
+ $this->setCurrencyId($v->getId());
+ }
+
+ $this->aCurrency = $v;
+
+ // 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->addOrder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Currency object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Currency The associated Currency object.
+ * @throws PropelException
+ */
+ public function getCurrency(PropelPDO $con = null)
+ {
+ 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->aCurrency;
+ }
+
+ /**
+ * Declares an association between this object and a Customer object.
+ *
+ * @param Customer $v
+ * @return Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomer(Customer $v = null)
+ {
+ 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->addOrder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated Customer object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @return Customer The associated Customer object.
+ * @throws PropelException
+ */
+ public function getCustomer(PropelPDO $con = null)
+ {
+ 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->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;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CouponOrder' == $relationName) {
+ $this->initCouponOrders();
+ }
+ if ('OrderProduct' == $relationName) {
+ $this->initOrderProducts();
+ }
+ }
+
+ /**
+ * Clears out the collCouponOrders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCouponOrders()
+ */
+ public function clearCouponOrders()
+ {
+ $this->collCouponOrders = null; // important to set this to null since that means it is uninitialized
+ $this->collCouponOrdersPartial = null;
+ }
+
+ /**
+ * reset is the collCouponOrders collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialCouponOrders($v = true)
+ {
+ $this->collCouponOrdersPartial = $v;
+ }
+
+ /**
+ * Initializes the collCouponOrders collection.
+ *
+ * By default this just sets the collCouponOrders collection to an empty array (like clearcollCouponOrders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCouponOrders($overrideExisting = true)
+ {
+ if (null !== $this->collCouponOrders && !$overrideExisting) {
+ return;
+ }
+ $this->collCouponOrders = new PropelObjectCollection();
+ $this->collCouponOrders->setModel('CouponOrder');
+ }
+
+ /**
+ * Gets an array of CouponOrder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this Order is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|CouponOrder[] List of CouponOrder objects
+ * @throws PropelException
+ */
+ public function getCouponOrders($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collCouponOrdersPartial && !$this->isNew();
+ if (null === $this->collCouponOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCouponOrders) {
+ // return empty collection
+ $this->initCouponOrders();
+ } else {
+ $collCouponOrders = CouponOrderQuery::create(null, $criteria)
+ ->filterByOrder($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) {
+ $this->initCouponOrders(false);
+
+ foreach($collCouponOrders as $obj) {
+ if (false == $this->collCouponOrders->contains($obj)) {
+ $this->collCouponOrders->append($obj);
+ }
+ }
+
+ $this->collCouponOrdersPartial = true;
+ }
+
+ return $collCouponOrders;
+ }
+
+ if($partial && $this->collCouponOrders) {
+ foreach($this->collCouponOrders as $obj) {
+ if($obj->isNew()) {
+ $collCouponOrders[] = $obj;
+ }
+ }
+ }
+
+ $this->collCouponOrders = $collCouponOrders;
+ $this->collCouponOrdersPartial = false;
+ }
+ }
+
+ return $this->collCouponOrders;
+ }
+
+ /**
+ * Sets a collection of CouponOrder objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $couponOrders A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setCouponOrders(PropelCollection $couponOrders, PropelPDO $con = null)
+ {
+ $this->couponOrdersScheduledForDeletion = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders);
+
+ foreach ($this->couponOrdersScheduledForDeletion as $couponOrderRemoved) {
+ $couponOrderRemoved->setOrder(null);
+ }
+
+ $this->collCouponOrders = null;
+ foreach ($couponOrders as $couponOrder) {
+ $this->addCouponOrder($couponOrder);
+ }
+
+ $this->collCouponOrders = $couponOrders;
+ $this->collCouponOrdersPartial = false;
+ }
+
+ /**
+ * Returns the number of related CouponOrder objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CouponOrder objects.
+ * @throws PropelException
+ */
+ public function countCouponOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCouponOrdersPartial && !$this->isNew();
+ if (null === $this->collCouponOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCouponOrders) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getCouponOrders());
+ }
+ $query = CouponOrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrder($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCouponOrders);
+ }
+ }
+
+ /**
+ * Method called to associate a CouponOrder object to this object
+ * through the CouponOrder foreign key attribute.
+ *
+ * @param CouponOrder $l CouponOrder
+ * @return Order The current object (for fluent API support)
+ */
+ public function addCouponOrder(CouponOrder $l)
+ {
+ if ($this->collCouponOrders === null) {
+ $this->initCouponOrders();
+ $this->collCouponOrdersPartial = true;
+ }
+ if (!$this->collCouponOrders->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddCouponOrder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CouponOrder $couponOrder The couponOrder object to add.
+ */
+ protected function doAddCouponOrder($couponOrder)
+ {
+ $this->collCouponOrders[]= $couponOrder;
+ $couponOrder->setOrder($this);
+ }
+
+ /**
+ * @param CouponOrder $couponOrder The couponOrder object to remove.
+ */
+ public function removeCouponOrder($couponOrder)
+ {
+ if ($this->getCouponOrders()->contains($couponOrder)) {
+ $this->collCouponOrders->remove($this->collCouponOrders->search($couponOrder));
+ if (null === $this->couponOrdersScheduledForDeletion) {
+ $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders;
+ $this->couponOrdersScheduledForDeletion->clear();
+ }
+ $this->couponOrdersScheduledForDeletion[]= $couponOrder;
+ $couponOrder->setOrder(null);
+ }
+ }
+
+ /**
+ * Clears out the collOrderProducts 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 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 getOrderProducts($criteria = null, PropelPDO $con = null)
+ {
+ $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);
+
+ 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;
+ }
+
+ /**
+ * @param OrderProduct $orderProduct The orderProduct object to add.
+ */
+ protected function doAddOrderProduct($orderProduct)
+ {
+ $this->collOrderProducts[]= $orderProduct;
+ $orderProduct->setOrder($this);
+ }
+
+ /**
+ * @param OrderProduct $orderProduct The orderProduct object to remove.
+ */
+ public function removeOrderProduct($orderProduct)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->ref = null;
+ $this->customer_id = null;
+ $this->address_invoice = null;
+ $this->address_delivery = null;
+ $this->invoice_date = null;
+ $this->currency_id = null;
+ $this->currency_rate = null;
+ $this->transaction = null;
+ $this->delivery_num = null;
+ $this->invoice = null;
+ $this->postage = null;
+ $this->payment = null;
+ $this->carrier = null;
+ $this->status_id = null;
+ $this->lang = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCouponOrders) {
+ foreach ($this->collCouponOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrderProducts) {
+ foreach ($this->collOrderProducts as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collCouponOrders instanceof PropelCollection) {
+ $this->collCouponOrders->clearIterator();
+ }
+ $this->collCouponOrders = null;
+ if ($this->collOrderProducts instanceof PropelCollection) {
+ $this->collOrderProducts->clearIterator();
+ }
+ $this->collOrderProducts = null;
+ $this->aCurrency = null;
+ $this->aCustomer = null;
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ $this->aOrderStatus = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderAddress.php b/core/lib/Thelia/Model/om/BaseOrderAddress.php
new file mode 100644
index 000000000..b5115d9f0
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderAddress.php
@@ -0,0 +1,2259 @@
+id;
+ }
+
+ /**
+ * Get the [customer_title_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerTitleId()
+ {
+ return $this->customer_title_id;
+ }
+
+ /**
+ * Get the [company] column value.
+ *
+ * @return string
+ */
+ public function getCompany()
+ {
+ return $this->company;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+ return $this->lastname;
+ }
+
+ /**
+ * Get the [address1] column value.
+ *
+ * @return string
+ */
+ public function getAddress1()
+ {
+ return $this->address1;
+ }
+
+ /**
+ * Get the [address2] column value.
+ *
+ * @return string
+ */
+ public function getAddress2()
+ {
+ return $this->address2;
+ }
+
+ /**
+ * Get the [address3] column value.
+ *
+ * @return string
+ */
+ public function getAddress3()
+ {
+ return $this->address3;
+ }
+
+ /**
+ * Get the [zipcode] column value.
+ *
+ * @return string
+ */
+ public function getZipcode()
+ {
+ return $this->zipcode;
+ }
+
+ /**
+ * Get the [city] column value.
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+ return $this->city;
+ }
+
+ /**
+ * Get the [phone] column value.
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+ return $this->phone;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [customer_title_id] column.
+ *
+ * @param int $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setCustomerTitleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_title_id !== $v) {
+ $this->customer_title_id = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::CUSTOMER_TITLE_ID;
+ }
+
+
+ return $this;
+ } // setCustomerTitleId()
+
+ /**
+ * Set the value of [company] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setCompany($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->company !== $v) {
+ $this->company = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::COMPANY;
+ }
+
+
+ return $this;
+ } // setCompany()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::LASTNAME;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [address1] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setAddress1($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address1 !== $v) {
+ $this->address1 = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::ADDRESS1;
+ }
+
+
+ return $this;
+ } // setAddress1()
+
+ /**
+ * Set the value of [address2] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setAddress2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address2 !== $v) {
+ $this->address2 = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::ADDRESS2;
+ }
+
+
+ return $this;
+ } // setAddress2()
+
+ /**
+ * Set the value of [address3] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setAddress3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address3 !== $v) {
+ $this->address3 = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::ADDRESS3;
+ }
+
+
+ return $this;
+ } // setAddress3()
+
+ /**
+ * Set the value of [zipcode] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setZipcode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->zipcode !== $v) {
+ $this->zipcode = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::ZIPCODE;
+ }
+
+
+ return $this;
+ } // setZipcode()
+
+ /**
+ * Set the value of [city] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setCity($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->city !== $v) {
+ $this->city = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::CITY;
+ }
+
+
+ return $this;
+ } // setCity()
+
+ /**
+ * Set the value of [phone] column.
+ *
+ * @param string $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setPhone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->phone !== $v) {
+ $this->phone = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::PHONE;
+ }
+
+
+ return $this;
+ } // setPhone()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = OrderAddressPeer::COUNTRY_ID;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderAddressPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderAddress The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderAddressPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->customer_title_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->company = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->firstname = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->lastname = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->address1 = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->address2 = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->address3 = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->zipcode = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->city = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
+ $this->phone = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
+ $this->country_id = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
+ $this->created_at = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
+ $this->updated_at = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 14; // 14 = OrderAddressPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating OrderAddress object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = OrderAddressPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collOrdersRelatedByAddressInvoice = null;
+
+ $this->collOrdersRelatedByAddressDelivery = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = OrderAddressQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderAddressPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderAddressPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderAddressPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderAddressPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::CUSTOMER_TITLE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CUSTOMER_TITLE_ID`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::COMPANY)) {
+ $modifiedColumns[':p' . $index++] = '`COMPANY`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`FIRSTNAME`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = '`LASTNAME`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::ADDRESS1)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS1`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::ADDRESS2)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS2`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::ADDRESS3)) {
+ $modifiedColumns[':p' . $index++] = '`ADDRESS3`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::ZIPCODE)) {
+ $modifiedColumns[':p' . $index++] = '`ZIPCODE`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::CITY)) {
+ $modifiedColumns[':p' . $index++] = '`CITY`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::PHONE)) {
+ $modifiedColumns[':p' . $index++] = '`PHONE`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(OrderAddressPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `order_address` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CUSTOMER_TITLE_ID`':
+ $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
+ break;
+ case '`COMPANY`':
+ $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR);
+ break;
+ case '`FIRSTNAME`':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case '`LASTNAME`':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS1`':
+ $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS2`':
+ $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
+ break;
+ case '`ADDRESS3`':
+ $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
+ break;
+ case '`ZIPCODE`':
+ $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
+ break;
+ case '`CITY`':
+ $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
+ break;
+ case '`PHONE`':
+ $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
+ break;
+ case '`COUNTRY_ID`':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderAddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCustomerTitleId();
+ break;
+ case 2:
+ return $this->getCompany();
+ break;
+ case 3:
+ return $this->getFirstname();
+ break;
+ case 4:
+ return $this->getLastname();
+ break;
+ case 5:
+ return $this->getAddress1();
+ break;
+ case 6:
+ return $this->getAddress2();
+ break;
+ case 7:
+ return $this->getAddress3();
+ break;
+ case 8:
+ return $this->getZipcode();
+ break;
+ case 9:
+ return $this->getCity();
+ break;
+ case 10:
+ return $this->getPhone();
+ break;
+ case 11:
+ return $this->getCountryId();
+ break;
+ case 12:
+ return $this->getCreatedAt();
+ break;
+ case 13:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderAddress'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderAddress'][$this->getPrimaryKey()] = true;
+ $keys = OrderAddressPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCustomerTitleId(),
+ $keys[2] => $this->getCompany(),
+ $keys[3] => $this->getFirstname(),
+ $keys[4] => $this->getLastname(),
+ $keys[5] => $this->getAddress1(),
+ $keys[6] => $this->getAddress2(),
+ $keys[7] => $this->getAddress3(),
+ $keys[8] => $this->getZipcode(),
+ $keys[9] => $this->getCity(),
+ $keys[10] => $this->getPhone(),
+ $keys[11] => $this->getCountryId(),
+ $keys[12] => $this->getCreatedAt(),
+ $keys[13] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collOrdersRelatedByAddressInvoice) {
+ $result['OrdersRelatedByAddressInvoice'] = $this->collOrdersRelatedByAddressInvoice->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrdersRelatedByAddressDelivery) {
+ $result['OrdersRelatedByAddressDelivery'] = $this->collOrdersRelatedByAddressDelivery->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderAddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCustomerTitleId($value);
+ break;
+ case 2:
+ $this->setCompany($value);
+ break;
+ case 3:
+ $this->setFirstname($value);
+ break;
+ case 4:
+ $this->setLastname($value);
+ break;
+ case 5:
+ $this->setAddress1($value);
+ break;
+ case 6:
+ $this->setAddress2($value);
+ break;
+ case 7:
+ $this->setAddress3($value);
+ break;
+ case 8:
+ $this->setZipcode($value);
+ break;
+ case 9:
+ $this->setCity($value);
+ break;
+ case 10:
+ $this->setPhone($value);
+ break;
+ case 11:
+ $this->setCountryId($value);
+ break;
+ case 12:
+ $this->setCreatedAt($value);
+ break;
+ case 13:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = OrderAddressPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCustomerTitleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCompany($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFirstname($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setLastname($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setAddress1($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setAddress2($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setAddress3($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setZipcode($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setCity($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setPhone($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCountryId($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderAddressPeer::ID)) $criteria->add(OrderAddressPeer::ID, $this->id);
+ if ($this->isColumnModified(OrderAddressPeer::CUSTOMER_TITLE_ID)) $criteria->add(OrderAddressPeer::CUSTOMER_TITLE_ID, $this->customer_title_id);
+ if ($this->isColumnModified(OrderAddressPeer::COMPANY)) $criteria->add(OrderAddressPeer::COMPANY, $this->company);
+ if ($this->isColumnModified(OrderAddressPeer::FIRSTNAME)) $criteria->add(OrderAddressPeer::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(OrderAddressPeer::LASTNAME)) $criteria->add(OrderAddressPeer::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(OrderAddressPeer::ADDRESS1)) $criteria->add(OrderAddressPeer::ADDRESS1, $this->address1);
+ if ($this->isColumnModified(OrderAddressPeer::ADDRESS2)) $criteria->add(OrderAddressPeer::ADDRESS2, $this->address2);
+ if ($this->isColumnModified(OrderAddressPeer::ADDRESS3)) $criteria->add(OrderAddressPeer::ADDRESS3, $this->address3);
+ if ($this->isColumnModified(OrderAddressPeer::ZIPCODE)) $criteria->add(OrderAddressPeer::ZIPCODE, $this->zipcode);
+ if ($this->isColumnModified(OrderAddressPeer::CITY)) $criteria->add(OrderAddressPeer::CITY, $this->city);
+ if ($this->isColumnModified(OrderAddressPeer::PHONE)) $criteria->add(OrderAddressPeer::PHONE, $this->phone);
+ if ($this->isColumnModified(OrderAddressPeer::COUNTRY_ID)) $criteria->add(OrderAddressPeer::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(OrderAddressPeer::CREATED_AT)) $criteria->add(OrderAddressPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderAddressPeer::UPDATED_AT)) $criteria->add(OrderAddressPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME);
+ $criteria->add(OrderAddressPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of OrderAddress (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCustomerTitleId($this->getCustomerTitleId());
+ $copyObj->setCompany($this->getCompany());
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setAddress1($this->getAddress1());
+ $copyObj->setAddress2($this->getAddress2());
+ $copyObj->setAddress3($this->getAddress3());
+ $copyObj->setZipcode($this->getZipcode());
+ $copyObj->setCity($this->getCity());
+ $copyObj->setPhone($this->getPhone());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return OrderAddress Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return OrderAddressPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new OrderAddressPeer();
+ }
+
+ 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.
+ *
+ * @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 getOrdersRelatedByAddressInvoice($criteria = null, PropelPDO $con = 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 {
+ return count($this->collOrdersRelatedByAddressInvoice);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to add.
+ */
+ protected function doAddOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice)
+ {
+ $this->collOrdersRelatedByAddressInvoice[]= $orderRelatedByAddressInvoice;
+ $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice($this);
+ }
+
+ /**
+ * @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.
+ *
+ * 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 getOrdersRelatedByAddressDelivery($criteria = null, PropelPDO $con = 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 {
+ return count($this->collOrdersRelatedByAddressDelivery);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove.
+ */
+ public function removeOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery)
+ {
+ 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);
+ }
+ }
+
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->customer_title_id = null;
+ $this->company = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->address1 = null;
+ $this->address2 = null;
+ $this->address3 = null;
+ $this->zipcode = null;
+ $this->city = null;
+ $this->phone = null;
+ $this->country_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ if ($this->collOrdersRelatedByAddressInvoice instanceof PropelCollection) {
+ $this->collOrdersRelatedByAddressInvoice->clearIterator();
+ }
+ $this->collOrdersRelatedByAddressInvoice = null;
+ if ($this->collOrdersRelatedByAddressDelivery instanceof PropelCollection) {
+ $this->collOrdersRelatedByAddressDelivery->clearIterator();
+ }
+ $this->collOrdersRelatedByAddressDelivery = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderAddressPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php b/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php
new file mode 100644
index 000000000..eab7445dd
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php
@@ -0,0 +1,835 @@
+ array ('Id', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'Phone', 'CountryId', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'countryId', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (OrderAddressPeer::ID, OrderAddressPeer::CUSTOMER_TITLE_ID, OrderAddressPeer::COMPANY, OrderAddressPeer::FIRSTNAME, OrderAddressPeer::LASTNAME, OrderAddressPeer::ADDRESS1, OrderAddressPeer::ADDRESS2, OrderAddressPeer::ADDRESS3, OrderAddressPeer::ZIPCODE, OrderAddressPeer::CITY, OrderAddressPeer::PHONE, OrderAddressPeer::COUNTRY_ID, OrderAddressPeer::CREATED_AT, OrderAddressPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'PHONE', 'COUNTRY_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'country_id', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. OrderAddressPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CustomerTitleId' => 1, 'Company' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Address1' => 5, 'Address2' => 6, 'Address3' => 7, 'Zipcode' => 8, 'City' => 9, 'Phone' => 10, 'CountryId' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'customerTitleId' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'countryId' => 11, 'createdAt' => 12, 'updatedAt' => 13, ),
+ BasePeer::TYPE_COLNAME => array (OrderAddressPeer::ID => 0, OrderAddressPeer::CUSTOMER_TITLE_ID => 1, OrderAddressPeer::COMPANY => 2, OrderAddressPeer::FIRSTNAME => 3, OrderAddressPeer::LASTNAME => 4, OrderAddressPeer::ADDRESS1 => 5, OrderAddressPeer::ADDRESS2 => 6, OrderAddressPeer::ADDRESS3 => 7, OrderAddressPeer::ZIPCODE => 8, OrderAddressPeer::CITY => 9, OrderAddressPeer::PHONE => 10, OrderAddressPeer::COUNTRY_ID => 11, OrderAddressPeer::CREATED_AT => 12, OrderAddressPeer::UPDATED_AT => 13, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CUSTOMER_TITLE_ID' => 1, 'COMPANY' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'ADDRESS1' => 5, 'ADDRESS2' => 6, 'ADDRESS3' => 7, 'ZIPCODE' => 8, 'CITY' => 9, 'PHONE' => 10, 'COUNTRY_ID' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'customer_title_id' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'country_id' => 11, 'created_at' => 12, 'updated_at' => 13, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = OrderAddressPeer::getFieldNames($toType);
+ $key = isset(OrderAddressPeer::$fieldKeys[$fromType][$name]) ? OrderAddressPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderAddressPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, OrderAddressPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return OrderAddressPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. OrderAddressPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(OrderAddressPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderAddressPeer::ID);
+ $criteria->addSelectColumn(OrderAddressPeer::CUSTOMER_TITLE_ID);
+ $criteria->addSelectColumn(OrderAddressPeer::COMPANY);
+ $criteria->addSelectColumn(OrderAddressPeer::FIRSTNAME);
+ $criteria->addSelectColumn(OrderAddressPeer::LASTNAME);
+ $criteria->addSelectColumn(OrderAddressPeer::ADDRESS1);
+ $criteria->addSelectColumn(OrderAddressPeer::ADDRESS2);
+ $criteria->addSelectColumn(OrderAddressPeer::ADDRESS3);
+ $criteria->addSelectColumn(OrderAddressPeer::ZIPCODE);
+ $criteria->addSelectColumn(OrderAddressPeer::CITY);
+ $criteria->addSelectColumn(OrderAddressPeer::PHONE);
+ $criteria->addSelectColumn(OrderAddressPeer::COUNTRY_ID);
+ $criteria->addSelectColumn(OrderAddressPeer::CREATED_AT);
+ $criteria->addSelectColumn(OrderAddressPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
+ $criteria->addSelectColumn($alias . '.COMPANY');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.ADDRESS1');
+ $criteria->addSelectColumn($alias . '.ADDRESS2');
+ $criteria->addSelectColumn($alias . '.ADDRESS3');
+ $criteria->addSelectColumn($alias . '.ZIPCODE');
+ $criteria->addSelectColumn($alias . '.CITY');
+ $criteria->addSelectColumn($alias . '.PHONE');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(OrderAddressPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return OrderAddress
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = OrderAddressPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return OrderAddressPeer::populateObjects(OrderAddressPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ OrderAddressPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param OrderAddress $obj A OrderAddress object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ OrderAddressPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A OrderAddress object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof OrderAddress) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderAddress object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(OrderAddressPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return OrderAddress Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(OrderAddressPeer::$instances[$key])) {
+ return OrderAddressPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ OrderAddressPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to order_address
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = OrderAddressPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = OrderAddressPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = OrderAddressPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderAddressPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderAddress object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = OrderAddressPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderAddressPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ OrderAddressPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(OrderAddressPeer::DATABASE_NAME)->getTable(OrderAddressPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseOrderAddressPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseOrderAddressPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderAddressTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return OrderAddressPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderAddress or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderAddress object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from OrderAddress object
+ }
+
+ if ($criteria->containsKey(OrderAddressPeer::ID) && $criteria->keyContainsValue(OrderAddressPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderAddressPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a OrderAddress or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderAddress object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(OrderAddressPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(OrderAddressPeer::ID);
+ $value = $criteria->remove(OrderAddressPeer::ID);
+ if ($value) {
+ $selectCriteria->add(OrderAddressPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(OrderAddressPeer::TABLE_NAME);
+ }
+
+ } else { // $values is OrderAddress object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the order_address table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(OrderAddressPeer::TABLE_NAME, $con, OrderAddressPeer::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
+ // instances get re-added by the select statement contained therein).
+ OrderAddressPeer::clearInstancePool();
+ OrderAddressPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderAddress or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderAddress object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ OrderAddressPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof OrderAddress) { // it's a model object
+ // invalidate the cache for this single object
+ OrderAddressPeer::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(OrderAddressPeer::DATABASE_NAME);
+ $criteria->add(OrderAddressPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ OrderAddressPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderAddressPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ OrderAddressPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given OrderAddress object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param OrderAddress $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(OrderAddressPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(OrderAddressPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(OrderAddressPeer::DATABASE_NAME, OrderAddressPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return OrderAddress
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = OrderAddressPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME);
+ $criteria->add(OrderAddressPeer::ID, $pk);
+
+ $v = OrderAddressPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return OrderAddress[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME);
+ $criteria->add(OrderAddressPeer::ID, $pks, Criteria::IN);
+ $objs = OrderAddressPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseOrderAddressPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseOrderAddressPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php
new file mode 100644
index 000000000..848b0a8b4
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php
@@ -0,0 +1,897 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return OrderAddress|OrderAddress[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderAddressPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderAddress A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CUSTOMER_TITLE_ID`, `COMPANY`, `FIRSTNAME`, `LASTNAME`, `ADDRESS1`, `ADDRESS2`, `ADDRESS3`, `ZIPCODE`, `CITY`, `PHONE`, `COUNTRY_ID`, `CREATED_AT`, `UPDATED_AT` FROM `order_address` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new OrderAddress();
+ $obj->hydrate($row);
+ OrderAddressPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderAddress|OrderAddress[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|OrderAddress[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderAddressPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderAddressPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_title_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
+ * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
+ * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
+ *
+ *
+ * @param mixed $customerTitleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
+ {
+ if (is_array($customerTitleId)) {
+ $useMinMax = false;
+ if (isset($customerTitleId['min'])) {
+ $this->addUsingAlias(OrderAddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerTitleId['max'])) {
+ $this->addUsingAlias(OrderAddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the company column
+ *
+ * Example usage:
+ *
+ * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue'
+ * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
+ *
+ *
+ * @param string $company The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCompany($company = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($company)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $company)) {
+ $company = str_replace('*', '%', $company);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::COMPANY, $company, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the address1 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue'
+ * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address1 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress1($address1 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address1)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address1)) {
+ $address1 = str_replace('*', '%', $address1);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::ADDRESS1, $address1, $comparison);
+ }
+
+ /**
+ * Filter the query on the address2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue'
+ * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address2 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress2($address2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address2)) {
+ $address2 = str_replace('*', '%', $address2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::ADDRESS2, $address2, $comparison);
+ }
+
+ /**
+ * Filter the query on the address3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue'
+ * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address3 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress3($address3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address3)) {
+ $address3 = str_replace('*', '%', $address3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::ADDRESS3, $address3, $comparison);
+ }
+
+ /**
+ * Filter the query on the zipcode column
+ *
+ * Example usage:
+ *
+ * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue'
+ * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
+ *
+ *
+ * @param string $zipcode The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByZipcode($zipcode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($zipcode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $zipcode)) {
+ $zipcode = str_replace('*', '%', $zipcode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::ZIPCODE, $zipcode, $comparison);
+ }
+
+ /**
+ * Filter the query on the city column
+ *
+ * Example usage:
+ *
+ * $query->filterByCity('fooValue'); // WHERE city = 'fooValue'
+ * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
+ *
+ *
+ * @param string $city The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCity($city = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($city)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $city)) {
+ $city = str_replace('*', '%', $city);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::CITY, $city, $comparison);
+ }
+
+ /**
+ * Filter the query on the phone column
+ *
+ * Example usage:
+ *
+ * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
+ * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
+ *
+ *
+ * @param string $phone The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByPhone($phone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($phone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $phone)) {
+ $phone = str_replace('*', '%', $phone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::PHONE, $phone, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(OrderAddressPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(OrderAddressPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderAddressPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderAddressPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Order object
+ *
+ * @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 filterByOrderRelatedByAddressInvoice($order, $comparison = null)
+ {
+ if ($order instanceof Order) {
+ return $this
+ ->addUsingAlias(OrderAddressPeer::ID, $order->getAddressInvoice(), $comparison);
+ } elseif ($order instanceof PropelObjectCollection) {
+ return $this
+ ->useOrderRelatedByAddressInvoiceQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderRelatedByAddressInvoice() only accepts arguments of type Order or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 joinOrderRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderRelatedByAddressInvoice');
+
+ // 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, 'OrderRelatedByAddressInvoice');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderRelatedByAddressInvoice relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->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 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 filterByOrderRelatedByAddressDelivery($order, $comparison = null)
+ {
+ if ($order instanceof Order) {
+ return $this
+ ->addUsingAlias(OrderAddressPeer::ID, $order->getAddressDelivery(), $comparison);
+ } elseif ($order instanceof PropelObjectCollection) {
+ return $this
+ ->useOrderRelatedByAddressDeliveryQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderRelatedByAddressDelivery() only accepts arguments of type Order or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 joinOrderRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderRelatedByAddressDelivery');
+
+ // 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, 'OrderRelatedByAddressDelivery');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderRelatedByAddressDelivery relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrderRelatedByAddressDelivery($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressDelivery', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param OrderAddress $orderAddress Object to remove from the list of results
+ *
+ * @return OrderAddressQuery The current query, for fluid interface
+ */
+ public function prune($orderAddress = null)
+ {
+ if ($orderAddress) {
+ $this->addUsingAlias(OrderAddressPeer::ID, $orderAddress->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderFeature.php b/core/lib/Thelia/Model/om/BaseOrderFeature.php
new file mode 100644
index 000000000..ffbc3aac4
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderFeature.php
@@ -0,0 +1,1210 @@
+id;
+ }
+
+ /**
+ * Get the [order_product_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderProductId()
+ {
+ return $this->order_product_id;
+ }
+
+ /**
+ * Get the [feature_desc] column value.
+ *
+ * @return string
+ */
+ public function getFeatureDesc()
+ {
+ return $this->feature_desc;
+ }
+
+ /**
+ * Get the [feature_av_desc] column value.
+ *
+ * @return string
+ */
+ public function getFeatureAvDesc()
+ {
+ return $this->feature_av_desc;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return OrderFeature The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderFeaturePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [order_product_id] column.
+ *
+ * @param int $v new value
+ * @return OrderFeature The current object (for fluent API support)
+ */
+ public function setOrderProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_product_id !== $v) {
+ $this->order_product_id = $v;
+ $this->modifiedColumns[] = OrderFeaturePeer::ORDER_PRODUCT_ID;
+ }
+
+ if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) {
+ $this->aOrderProduct = null;
+ }
+
+
+ return $this;
+ } // setOrderProductId()
+
+ /**
+ * Set the value of [feature_desc] column.
+ *
+ * @param string $v new value
+ * @return OrderFeature The current object (for fluent API support)
+ */
+ public function setFeatureDesc($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->feature_desc !== $v) {
+ $this->feature_desc = $v;
+ $this->modifiedColumns[] = OrderFeaturePeer::FEATURE_DESC;
+ }
+
+
+ return $this;
+ } // setFeatureDesc()
+
+ /**
+ * Set the value of [feature_av_desc] column.
+ *
+ * @param string $v new value
+ * @return OrderFeature The current object (for fluent API support)
+ */
+ public function setFeatureAvDesc($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->feature_av_desc !== $v) {
+ $this->feature_av_desc = $v;
+ $this->modifiedColumns[] = OrderFeaturePeer::FEATURE_AV_DESC;
+ }
+
+
+ return $this;
+ } // setFeatureAvDesc()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderFeature The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderFeaturePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderFeature The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderFeaturePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->order_product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->feature_desc = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->feature_av_desc = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = OrderFeaturePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating OrderFeature object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) {
+ $this->aOrderProduct = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = OrderFeaturePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrderProduct = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = OrderFeatureQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderFeaturePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderFeaturePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderFeaturePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderFeaturePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(OrderFeaturePeer::ORDER_PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ORDER_PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(OrderFeaturePeer::FEATURE_DESC)) {
+ $modifiedColumns[':p' . $index++] = '`FEATURE_DESC`';
+ }
+ if ($this->isColumnModified(OrderFeaturePeer::FEATURE_AV_DESC)) {
+ $modifiedColumns[':p' . $index++] = '`FEATURE_AV_DESC`';
+ }
+ if ($this->isColumnModified(OrderFeaturePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `order_feature` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`ORDER_PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT);
+ break;
+ case '`FEATURE_DESC`':
+ $stmt->bindValue($identifier, $this->feature_desc, PDO::PARAM_STR);
+ break;
+ case '`FEATURE_AV_DESC`':
+ $stmt->bindValue($identifier, $this->feature_av_desc, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderFeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getOrderProductId();
+ break;
+ case 2:
+ return $this->getFeatureDesc();
+ break;
+ case 3:
+ return $this->getFeatureAvDesc();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderFeature'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderFeature'][$this->getPrimaryKey()] = true;
+ $keys = OrderFeaturePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getOrderProductId(),
+ $keys[2] => $this->getFeatureDesc(),
+ $keys[3] => $this->getFeatureAvDesc(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrderProduct) {
+ $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderFeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setOrderProductId($value);
+ break;
+ case 2:
+ $this->setFeatureDesc($value);
+ break;
+ case 3:
+ $this->setFeatureAvDesc($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = OrderFeaturePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setFeatureDesc($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFeatureAvDesc($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderFeaturePeer::ID)) $criteria->add(OrderFeaturePeer::ID, $this->id);
+ if ($this->isColumnModified(OrderFeaturePeer::ORDER_PRODUCT_ID)) $criteria->add(OrderFeaturePeer::ORDER_PRODUCT_ID, $this->order_product_id);
+ if ($this->isColumnModified(OrderFeaturePeer::FEATURE_DESC)) $criteria->add(OrderFeaturePeer::FEATURE_DESC, $this->feature_desc);
+ if ($this->isColumnModified(OrderFeaturePeer::FEATURE_AV_DESC)) $criteria->add(OrderFeaturePeer::FEATURE_AV_DESC, $this->feature_av_desc);
+ if ($this->isColumnModified(OrderFeaturePeer::CREATED_AT)) $criteria->add(OrderFeaturePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) $criteria->add(OrderFeaturePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME);
+ $criteria->add(OrderFeaturePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of OrderFeature (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setOrderProductId($this->getOrderProductId());
+ $copyObj->setFeatureDesc($this->getFeatureDesc());
+ $copyObj->setFeatureAvDesc($this->getFeatureAvDesc());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return OrderFeature Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return OrderFeaturePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new OrderFeaturePeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a OrderProduct object.
+ *
+ * @param OrderProduct $v
+ * @return OrderFeature The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderProduct(OrderProduct $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->order_product_id = null;
+ $this->feature_desc = null;
+ $this->feature_av_desc = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aOrderProduct = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderFeaturePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php b/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php
new file mode 100644
index 000000000..08c6a6e47
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php
@@ -0,0 +1,1027 @@
+ array ('Id', 'OrderProductId', 'FeatureDesc', 'FeatureAvDesc', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'orderProductId', 'featureDesc', 'featureAvDesc', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (OrderFeaturePeer::ID, OrderFeaturePeer::ORDER_PRODUCT_ID, OrderFeaturePeer::FEATURE_DESC, OrderFeaturePeer::FEATURE_AV_DESC, OrderFeaturePeer::CREATED_AT, OrderFeaturePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ORDER_PRODUCT_ID', 'FEATURE_DESC', 'FEATURE_AV_DESC', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'order_product_id', 'feature_desc', 'feature_av_desc', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. OrderFeaturePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'OrderProductId' => 1, 'FeatureDesc' => 2, 'FeatureAvDesc' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'orderProductId' => 1, 'featureDesc' => 2, 'featureAvDesc' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ BasePeer::TYPE_COLNAME => array (OrderFeaturePeer::ID => 0, OrderFeaturePeer::ORDER_PRODUCT_ID => 1, OrderFeaturePeer::FEATURE_DESC => 2, OrderFeaturePeer::FEATURE_AV_DESC => 3, OrderFeaturePeer::CREATED_AT => 4, OrderFeaturePeer::UPDATED_AT => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'FEATURE_DESC' => 2, 'FEATURE_AV_DESC' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'order_product_id' => 1, 'feature_desc' => 2, 'feature_av_desc' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = OrderFeaturePeer::getFieldNames($toType);
+ $key = isset(OrderFeaturePeer::$fieldKeys[$fromType][$name]) ? OrderFeaturePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderFeaturePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, OrderFeaturePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return OrderFeaturePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. OrderFeaturePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(OrderFeaturePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderFeaturePeer::ID);
+ $criteria->addSelectColumn(OrderFeaturePeer::ORDER_PRODUCT_ID);
+ $criteria->addSelectColumn(OrderFeaturePeer::FEATURE_DESC);
+ $criteria->addSelectColumn(OrderFeaturePeer::FEATURE_AV_DESC);
+ $criteria->addSelectColumn(OrderFeaturePeer::CREATED_AT);
+ $criteria->addSelectColumn(OrderFeaturePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_DESC');
+ $criteria->addSelectColumn($alias . '.FEATURE_AV_DESC');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return OrderFeature
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = OrderFeaturePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return OrderFeaturePeer::populateObjects(OrderFeaturePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ OrderFeaturePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param OrderFeature $obj A OrderFeature object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ OrderFeaturePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A OrderFeature object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof OrderFeature) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderFeature object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(OrderFeaturePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return OrderFeature Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(OrderFeaturePeer::$instances[$key])) {
+ return OrderFeaturePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ OrderFeaturePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to order_feature
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = OrderFeaturePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = OrderFeaturePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderFeaturePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderFeature object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = OrderFeaturePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + OrderFeaturePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderFeaturePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ OrderFeaturePeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(OrderFeaturePeer::DATABASE_NAME)->getTable(OrderFeaturePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseOrderFeaturePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseOrderFeaturePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderFeatureTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return OrderFeaturePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderFeature or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderFeature object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from OrderFeature object
+ }
+
+ if ($criteria->containsKey(OrderFeaturePeer::ID) && $criteria->keyContainsValue(OrderFeaturePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderFeaturePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a OrderFeature or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderFeature object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(OrderFeaturePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(OrderFeaturePeer::ID);
+ $value = $criteria->remove(OrderFeaturePeer::ID);
+ if ($value) {
+ $selectCriteria->add(OrderFeaturePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(OrderFeaturePeer::TABLE_NAME);
+ }
+
+ } else { // $values is OrderFeature object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the order_feature table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ OrderFeaturePeer::clearInstancePool();
+ OrderFeaturePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderFeature or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderFeature object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ OrderFeaturePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given OrderFeature object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param OrderFeature $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(OrderFeaturePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(OrderFeaturePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(OrderFeaturePeer::DATABASE_NAME, OrderFeaturePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return OrderFeature
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = OrderFeaturePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME);
+ $criteria->add(OrderFeaturePeer::ID, $pk);
+
+ $v = OrderFeaturePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return OrderFeature[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME);
+ $criteria->add(OrderFeaturePeer::ID, $pks, Criteria::IN);
+ $objs = OrderFeaturePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseOrderFeaturePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseOrderFeaturePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php
new file mode 100644
index 000000000..6e1cb964c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php
@@ -0,0 +1,547 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return OrderFeature|OrderFeature[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderFeaturePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderFeature A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `ORDER_PRODUCT_ID`, `FEATURE_DESC`, `FEATURE_AV_DESC`, `CREATED_AT`, `UPDATED_AT` FROM `order_feature` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new OrderFeature();
+ $obj->hydrate($row);
+ OrderFeaturePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderFeature|OrderFeature[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|OrderFeature[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderFeaturePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderFeaturePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(OrderFeaturePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234
+ * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34)
+ * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12
+ *
+ *
+ * @see filterByOrderProduct()
+ *
+ * @param mixed $orderProductId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByOrderProductId($orderProductId = null, $comparison = null)
+ {
+ if (is_array($orderProductId)) {
+ $useMinMax = false;
+ if (isset($orderProductId['min'])) {
+ $this->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderProductId['max'])) {
+ $this->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProductId, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_desc column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureDesc('fooValue'); // WHERE feature_desc = 'fooValue'
+ * $query->filterByFeatureDesc('%fooValue%'); // WHERE feature_desc LIKE '%fooValue%'
+ *
+ *
+ * @param string $featureDesc The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByFeatureDesc($featureDesc = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($featureDesc)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $featureDesc)) {
+ $featureDesc = str_replace('*', '%', $featureDesc);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeaturePeer::FEATURE_DESC, $featureDesc, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_av_desc column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureAvDesc('fooValue'); // WHERE feature_av_desc = 'fooValue'
+ * $query->filterByFeatureAvDesc('%fooValue%'); // WHERE feature_av_desc LIKE '%fooValue%'
+ *
+ *
+ * @param string $featureAvDesc The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAvDesc($featureAvDesc = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($featureAvDesc)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $featureAvDesc)) {
+ $featureAvDesc = str_replace('*', '%', $featureAvDesc);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeaturePeer::FEATURE_AV_DESC, $featureAvDesc, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 OrderFeatureQuery 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(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison);
+ } elseif ($orderProduct instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $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 OrderFeatureQuery 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
+ *
+ * @param OrderFeature $orderFeature Object to remove from the list of results
+ *
+ * @return OrderFeatureQuery The current query, for fluid interface
+ */
+ public function prune($orderFeature = null)
+ {
+ if ($orderFeature) {
+ $this->addUsingAlias(OrderFeaturePeer::ID, $orderFeature->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderPeer.php b/core/lib/Thelia/Model/om/BaseOrderPeer.php
new file mode 100644
index 000000000..1926b7931
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderPeer.php
@@ -0,0 +1,2633 @@
+ array ('Id', 'Ref', 'CustomerId', 'AddressInvoice', 'AddressDelivery', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'Transaction', 'DeliveryNum', 'Invoice', 'Postage', 'Payment', 'Carrier', 'StatusId', 'Lang', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'ref', 'customerId', 'addressInvoice', 'addressDelivery', 'invoiceDate', 'currencyId', 'currencyRate', 'transaction', 'deliveryNum', 'invoice', 'postage', 'payment', 'carrier', 'statusId', 'lang', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (OrderPeer::ID, OrderPeer::REF, OrderPeer::CUSTOMER_ID, OrderPeer::ADDRESS_INVOICE, OrderPeer::ADDRESS_DELIVERY, OrderPeer::INVOICE_DATE, OrderPeer::CURRENCY_ID, OrderPeer::CURRENCY_RATE, OrderPeer::TRANSACTION, OrderPeer::DELIVERY_NUM, OrderPeer::INVOICE, OrderPeer::POSTAGE, OrderPeer::PAYMENT, OrderPeer::CARRIER, OrderPeer::STATUS_ID, OrderPeer::LANG, OrderPeer::CREATED_AT, OrderPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'REF', 'CUSTOMER_ID', 'ADDRESS_INVOICE', 'ADDRESS_DELIVERY', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION', 'DELIVERY_NUM', 'INVOICE', 'POSTAGE', 'PAYMENT', 'CARRIER', 'STATUS_ID', 'LANG', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'ref', 'customer_id', 'address_invoice', 'address_delivery', 'invoice_date', 'currency_id', 'currency_rate', 'transaction', 'delivery_num', 'invoice', 'postage', 'payment', 'carrier', 'status_id', 'lang', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. OrderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'AddressInvoice' => 3, 'AddressDelivery' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'Transaction' => 8, 'DeliveryNum' => 9, 'Invoice' => 10, 'Postage' => 11, 'Payment' => 12, 'Carrier' => 13, 'StatusId' => 14, 'Lang' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'ref' => 1, 'customerId' => 2, 'addressInvoice' => 3, 'addressDelivery' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transaction' => 8, 'deliveryNum' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'statusId' => 14, 'lang' => 15, 'createdAt' => 16, 'updatedAt' => 17, ),
+ BasePeer::TYPE_COLNAME => array (OrderPeer::ID => 0, OrderPeer::REF => 1, OrderPeer::CUSTOMER_ID => 2, OrderPeer::ADDRESS_INVOICE => 3, OrderPeer::ADDRESS_DELIVERY => 4, OrderPeer::INVOICE_DATE => 5, OrderPeer::CURRENCY_ID => 6, OrderPeer::CURRENCY_RATE => 7, OrderPeer::TRANSACTION => 8, OrderPeer::DELIVERY_NUM => 9, OrderPeer::INVOICE => 10, OrderPeer::POSTAGE => 11, OrderPeer::PAYMENT => 12, OrderPeer::CARRIER => 13, OrderPeer::STATUS_ID => 14, OrderPeer::LANG => 15, OrderPeer::CREATED_AT => 16, OrderPeer::UPDATED_AT => 17, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_INVOICE' => 3, 'ADDRESS_DELIVERY' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION' => 8, 'DELIVERY_NUM' => 9, 'INVOICE' => 10, 'POSTAGE' => 11, 'PAYMENT' => 12, 'CARRIER' => 13, 'STATUS_ID' => 14, 'LANG' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'ref' => 1, 'customer_id' => 2, 'address_invoice' => 3, 'address_delivery' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction' => 8, 'delivery_num' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'status_id' => 14, 'lang' => 15, 'created_at' => 16, 'updated_at' => 17, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = OrderPeer::getFieldNames($toType);
+ $key = isset(OrderPeer::$fieldKeys[$fromType][$name]) ? OrderPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, OrderPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return OrderPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. OrderPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(OrderPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderPeer::ID);
+ $criteria->addSelectColumn(OrderPeer::REF);
+ $criteria->addSelectColumn(OrderPeer::CUSTOMER_ID);
+ $criteria->addSelectColumn(OrderPeer::ADDRESS_INVOICE);
+ $criteria->addSelectColumn(OrderPeer::ADDRESS_DELIVERY);
+ $criteria->addSelectColumn(OrderPeer::INVOICE_DATE);
+ $criteria->addSelectColumn(OrderPeer::CURRENCY_ID);
+ $criteria->addSelectColumn(OrderPeer::CURRENCY_RATE);
+ $criteria->addSelectColumn(OrderPeer::TRANSACTION);
+ $criteria->addSelectColumn(OrderPeer::DELIVERY_NUM);
+ $criteria->addSelectColumn(OrderPeer::INVOICE);
+ $criteria->addSelectColumn(OrderPeer::POSTAGE);
+ $criteria->addSelectColumn(OrderPeer::PAYMENT);
+ $criteria->addSelectColumn(OrderPeer::CARRIER);
+ $criteria->addSelectColumn(OrderPeer::STATUS_ID);
+ $criteria->addSelectColumn(OrderPeer::LANG);
+ $criteria->addSelectColumn(OrderPeer::CREATED_AT);
+ $criteria->addSelectColumn(OrderPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_ID');
+ $criteria->addSelectColumn($alias . '.ADDRESS_INVOICE');
+ $criteria->addSelectColumn($alias . '.ADDRESS_DELIVERY');
+ $criteria->addSelectColumn($alias . '.INVOICE_DATE');
+ $criteria->addSelectColumn($alias . '.CURRENCY_ID');
+ $criteria->addSelectColumn($alias . '.CURRENCY_RATE');
+ $criteria->addSelectColumn($alias . '.TRANSACTION');
+ $criteria->addSelectColumn($alias . '.DELIVERY_NUM');
+ $criteria->addSelectColumn($alias . '.INVOICE');
+ $criteria->addSelectColumn($alias . '.POSTAGE');
+ $criteria->addSelectColumn($alias . '.PAYMENT');
+ $criteria->addSelectColumn($alias . '.CARRIER');
+ $criteria->addSelectColumn($alias . '.STATUS_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(OrderPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Order
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = OrderPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return OrderPeer::populateObjects(OrderPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ OrderPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Order $obj A Order object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ OrderPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Order object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Order) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Order object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(OrderPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Order Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(OrderPeer::$instances[$key])) {
+ return OrderPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ OrderPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to order
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in CouponOrderPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CouponOrderPeer::clearInstancePool();
+ // Invalidate objects in OrderProductPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderProductPeer::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = OrderPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = OrderPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Order object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = OrderPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + OrderPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ OrderPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ 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;
+
+ // We need to set the primary table name, since in the case that there 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::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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(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::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 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
+ * @return array Array of Order objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCurrency(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;
+ CurrencyPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::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 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CurrencyPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CurrencyPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CurrencyPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (Order) to $obj2 (Currency)
+ $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 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 Order 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(OrderPeer::DATABASE_NAME);
+ }
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
+ CustomerPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::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 = 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 (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
+
+ $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(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::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::doCount($criteria, $con);
+
+ if ($row = $stmt->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.
+ *
+ * @param 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 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(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;
+
+ 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();
+
+ 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 loaded
+
+ // Add the $obj1 (Order) to the collection in $obj2 (Currency)
+ $obj2->addOrder($obj1);
+ } // 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 (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;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * 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.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ 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;
+
+ // We need to set the primary table name, since in the case that there 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::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);
+
+ if ($row = $stmt->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(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::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);
+
+ if ($row = $stmt->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 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
+ * @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 doSelectJoinAllExceptCurrency(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;
+
+ CustomerPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS;
+
+ 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);
+ $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 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 (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
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Selects a collection of Order 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 Order 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(OrderPeer::DATABASE_NAME);
+ }
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
+
+ CurrencyPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
+
+ 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);
+ $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 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
+
+ $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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(OrderPeer::DATABASE_NAME)->getTable(OrderPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseOrderPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseOrderPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return OrderPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Order or Criteria object.
+ *
+ * @param mixed $values Criteria or Order object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Order object
+ }
+
+ if ($criteria->containsKey(OrderPeer::ID) && $criteria->keyContainsValue(OrderPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Order or Criteria object.
+ *
+ * @param mixed $values Criteria or Order object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(OrderPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(OrderPeer::ID);
+ $value = $criteria->remove(OrderPeer::ID);
+ if ($value) {
+ $selectCriteria->add(OrderPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Order object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the order table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ OrderPeer::clearInstancePool();
+ OrderPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Order or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Order object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(OrderPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ OrderPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Order object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Order $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(OrderPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(OrderPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(OrderPeer::DATABASE_NAME, OrderPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Order
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = OrderPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(OrderPeer::DATABASE_NAME);
+ $criteria->add(OrderPeer::ID, $pk);
+
+ $v = OrderPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Order[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(OrderPeer::DATABASE_NAME);
+ $criteria->add(OrderPeer::ID, $pks, Criteria::IN);
+ $objs = OrderPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseOrderPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseOrderPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseOrderProduct.php b/core/lib/Thelia/Model/om/BaseOrderProduct.php
new file mode 100644
index 000000000..191349de4
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderProduct.php
@@ -0,0 +1,1824 @@
+id;
+ }
+
+ /**
+ * Get the [order_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderId()
+ {
+ return $this->order_id;
+ }
+
+ /**
+ * Get the [product_ref] column value.
+ *
+ * @return string
+ */
+ public function getProductRef()
+ {
+ return $this->product_ref;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [quantity] column value.
+ *
+ * @return double
+ */
+ public function getQuantity()
+ {
+ return $this->quantity;
+ }
+
+ /**
+ * Get the [price] column value.
+ *
+ * @return double
+ */
+ public function getPrice()
+ {
+ return $this->price;
+ }
+
+ /**
+ * Get the [tax] column value.
+ *
+ * @return double
+ */
+ public function getTax()
+ {
+ return $this->tax;
+ }
+
+ /**
+ * Get the [parent] column value.
+ *
+ * @return int
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderProductPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [order_id] column.
+ *
+ * @param int $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setOrderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_id !== $v) {
+ $this->order_id = $v;
+ $this->modifiedColumns[] = OrderProductPeer::ORDER_ID;
+ }
+
+ if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
+ $this->aOrder = null;
+ }
+
+
+ return $this;
+ } // setOrderId()
+
+ /**
+ * Set the value of [product_ref] column.
+ *
+ * @param string $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setProductRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->product_ref !== $v) {
+ $this->product_ref = $v;
+ $this->modifiedColumns[] = OrderProductPeer::PRODUCT_REF;
+ }
+
+
+ return $this;
+ } // setProductRef()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = OrderProductPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = OrderProductPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = OrderProductPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [quantity] column.
+ *
+ * @param double $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setQuantity($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->quantity !== $v) {
+ $this->quantity = $v;
+ $this->modifiedColumns[] = OrderProductPeer::QUANTITY;
+ }
+
+
+ return $this;
+ } // setQuantity()
+
+ /**
+ * Set the value of [price] column.
+ *
+ * @param double $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setPrice($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->price !== $v) {
+ $this->price = $v;
+ $this->modifiedColumns[] = OrderProductPeer::PRICE;
+ }
+
+
+ return $this;
+ } // setPrice()
+
+ /**
+ * Set the value of [tax] column.
+ *
+ * @param double $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setTax($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->tax !== $v) {
+ $this->tax = $v;
+ $this->modifiedColumns[] = OrderProductPeer::TAX;
+ }
+
+
+ return $this;
+ } // setTax()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setParent($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent !== $v) {
+ $this->parent = $v;
+ $this->modifiedColumns[] = OrderProductPeer::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderProductPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderProduct The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderProductPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->order_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->product_ref = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->quantity = ($row[$startcol + 6] !== null) ? (double) $row[$startcol + 6] : null;
+ $this->price = ($row[$startcol + 7] !== null) ? (double) $row[$startcol + 7] : null;
+ $this->tax = ($row[$startcol + 8] !== null) ? (double) $row[$startcol + 8] : null;
+ $this->parent = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
+ $this->created_at = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
+ $this->updated_at = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 12; // 12 = OrderProductPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating OrderProduct object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) {
+ $this->aOrder = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = OrderProductPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrder = null;
+ $this->collOrderFeatures = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = OrderProductQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderProductPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->orderFeaturesScheduledForDeletion !== null) {
+ if (!$this->orderFeaturesScheduledForDeletion->isEmpty()) {
+ OrderFeatureQuery::create()
+ ->filterByPrimaryKeys($this->orderFeaturesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderFeaturesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderFeatures !== null) {
+ foreach ($this->collOrderFeatures as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderProductPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderProductPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::ORDER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`ORDER_ID`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::PRODUCT_REF)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_REF`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::QUANTITY)) {
+ $modifiedColumns[':p' . $index++] = '`QUANTITY`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::PRICE)) {
+ $modifiedColumns[':p' . $index++] = '`PRICE`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::TAX)) {
+ $modifiedColumns[':p' . $index++] = '`TAX`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::PARENT)) {
+ $modifiedColumns[':p' . $index++] = '`PARENT`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(OrderProductPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `order_product` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`ORDER_ID`':
+ $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT);
+ break;
+ case '`PRODUCT_REF`':
+ $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`QUANTITY`':
+ $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR);
+ break;
+ case '`PRICE`':
+ $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
+ break;
+ case '`TAX`':
+ $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR);
+ break;
+ case '`PARENT`':
+ $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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 = OrderProductPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ if ($this->collOrderFeatures !== null) {
+ foreach ($this->collOrderFeatures as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getOrderId();
+ break;
+ case 2:
+ return $this->getProductRef();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getQuantity();
+ break;
+ case 7:
+ return $this->getPrice();
+ break;
+ case 8:
+ return $this->getTax();
+ break;
+ case 9:
+ return $this->getParent();
+ break;
+ case 10:
+ return $this->getCreatedAt();
+ break;
+ case 11:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()] = true;
+ $keys = OrderProductPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getOrderId(),
+ $keys[2] => $this->getProductRef(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getQuantity(),
+ $keys[7] => $this->getPrice(),
+ $keys[8] => $this->getTax(),
+ $keys[9] => $this->getParent(),
+ $keys[10] => $this->getCreatedAt(),
+ $keys[11] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrder) {
+ $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collOrderFeatures) {
+ $result['OrderFeatures'] = $this->collOrderFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setOrderId($value);
+ break;
+ case 2:
+ $this->setProductRef($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setQuantity($value);
+ break;
+ case 7:
+ $this->setPrice($value);
+ break;
+ case 8:
+ $this->setTax($value);
+ break;
+ case 9:
+ $this->setParent($value);
+ break;
+ case 10:
+ $this->setCreatedAt($value);
+ break;
+ case 11:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = OrderProductPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setProductRef($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setQuantity($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setPrice($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setTax($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setParent($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderProductPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderProductPeer::ID)) $criteria->add(OrderProductPeer::ID, $this->id);
+ if ($this->isColumnModified(OrderProductPeer::ORDER_ID)) $criteria->add(OrderProductPeer::ORDER_ID, $this->order_id);
+ if ($this->isColumnModified(OrderProductPeer::PRODUCT_REF)) $criteria->add(OrderProductPeer::PRODUCT_REF, $this->product_ref);
+ if ($this->isColumnModified(OrderProductPeer::TITLE)) $criteria->add(OrderProductPeer::TITLE, $this->title);
+ if ($this->isColumnModified(OrderProductPeer::DESCRIPTION)) $criteria->add(OrderProductPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(OrderProductPeer::CHAPO)) $criteria->add(OrderProductPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(OrderProductPeer::QUANTITY)) $criteria->add(OrderProductPeer::QUANTITY, $this->quantity);
+ if ($this->isColumnModified(OrderProductPeer::PRICE)) $criteria->add(OrderProductPeer::PRICE, $this->price);
+ if ($this->isColumnModified(OrderProductPeer::TAX)) $criteria->add(OrderProductPeer::TAX, $this->tax);
+ if ($this->isColumnModified(OrderProductPeer::PARENT)) $criteria->add(OrderProductPeer::PARENT, $this->parent);
+ if ($this->isColumnModified(OrderProductPeer::CREATED_AT)) $criteria->add(OrderProductPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderProductPeer::UPDATED_AT)) $criteria->add(OrderProductPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderProductPeer::DATABASE_NAME);
+ $criteria->add(OrderProductPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of OrderProduct (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setOrderId($this->getOrderId());
+ $copyObj->setProductRef($this->getProductRef());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setQuantity($this->getQuantity());
+ $copyObj->setPrice($this->getPrice());
+ $copyObj->setTax($this->getTax());
+ $copyObj->setParent($this->getParent());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return OrderProduct Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return OrderProductPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new OrderProductPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Order object.
+ *
+ * @param Order $v
+ * @return OrderProduct The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrder(Order $v = null)
+ {
+ 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->addOrderProduct($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->addOrderProducts($this);
+ */
+ }
+
+ return $this->aOrder;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('OrderFeature' == $relationName) {
+ $this->initOrderFeatures();
+ }
+ }
+
+ /**
+ * 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 PropelObjectCollection|OrderFeature[] List of OrderFeature objects
+ * @throws PropelException
+ */
+ 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);
+
+ 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->collOrderFeatures;
+ }
+
+ /**
+ * 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 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 countOrderFeatures(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $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();
+ }
+
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->order_id = null;
+ $this->product_ref = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->quantity = null;
+ $this->price = null;
+ $this->tax = null;
+ $this->parent = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collOrderFeatures) {
+ foreach ($this->collOrderFeatures as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collOrderFeatures instanceof PropelCollection) {
+ $this->collOrderFeatures->clearIterator();
+ }
+ $this->collOrderFeatures = null;
+ $this->aOrder = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderProductPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderProductPeer.php b/core/lib/Thelia/Model/om/BaseOrderProductPeer.php
new file mode 100644
index 000000000..35a94e6c3
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderProductPeer.php
@@ -0,0 +1,1061 @@
+ array ('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (OrderProductPeer::ID, OrderProductPeer::ORDER_ID, OrderProductPeer::PRODUCT_REF, OrderProductPeer::TITLE, OrderProductPeer::DESCRIPTION, OrderProductPeer::CHAPO, OrderProductPeer::QUANTITY, OrderProductPeer::PRICE, OrderProductPeer::TAX, OrderProductPeer::PARENT, OrderProductPeer::CREATED_AT, OrderProductPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. OrderProductPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Quantity' => 6, 'Price' => 7, 'Tax' => 8, 'Parent' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'orderId' => 1, 'productRef' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'createdAt' => 10, 'updatedAt' => 11, ),
+ BasePeer::TYPE_COLNAME => array (OrderProductPeer::ID => 0, OrderProductPeer::ORDER_ID => 1, OrderProductPeer::PRODUCT_REF => 2, OrderProductPeer::TITLE => 3, OrderProductPeer::DESCRIPTION => 4, OrderProductPeer::CHAPO => 5, OrderProductPeer::QUANTITY => 6, OrderProductPeer::PRICE => 7, OrderProductPeer::TAX => 8, OrderProductPeer::PARENT => 9, OrderProductPeer::CREATED_AT => 10, OrderProductPeer::UPDATED_AT => 11, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'QUANTITY' => 6, 'PRICE' => 7, 'TAX' => 8, 'PARENT' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'created_at' => 10, 'updated_at' => 11, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = OrderProductPeer::getFieldNames($toType);
+ $key = isset(OrderProductPeer::$fieldKeys[$fromType][$name]) ? OrderProductPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderProductPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, OrderProductPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return OrderProductPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. OrderProductPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(OrderProductPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderProductPeer::ID);
+ $criteria->addSelectColumn(OrderProductPeer::ORDER_ID);
+ $criteria->addSelectColumn(OrderProductPeer::PRODUCT_REF);
+ $criteria->addSelectColumn(OrderProductPeer::TITLE);
+ $criteria->addSelectColumn(OrderProductPeer::DESCRIPTION);
+ $criteria->addSelectColumn(OrderProductPeer::CHAPO);
+ $criteria->addSelectColumn(OrderProductPeer::QUANTITY);
+ $criteria->addSelectColumn(OrderProductPeer::PRICE);
+ $criteria->addSelectColumn(OrderProductPeer::TAX);
+ $criteria->addSelectColumn(OrderProductPeer::PARENT);
+ $criteria->addSelectColumn(OrderProductPeer::CREATED_AT);
+ $criteria->addSelectColumn(OrderProductPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ORDER_ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_REF');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.QUANTITY');
+ $criteria->addSelectColumn($alias . '.PRICE');
+ $criteria->addSelectColumn($alias . '.TAX');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(OrderProductPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderProductPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(OrderProductPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return OrderProduct
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = OrderProductPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return OrderProductPeer::populateObjects(OrderProductPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ OrderProductPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderProductPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param OrderProduct $obj A OrderProduct object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ OrderProductPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A OrderProduct object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof OrderProduct) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderProduct object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(OrderProductPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return OrderProduct Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(OrderProductPeer::$instances[$key])) {
+ return OrderProductPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ OrderProductPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to order_product
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in OrderFeaturePeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderFeaturePeer::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = OrderProductPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = OrderProductPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = OrderProductPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderProductPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderProduct object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = OrderProductPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + OrderProductPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderProductPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ OrderProductPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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(OrderProductPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderProductPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderProductPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderProductPeer::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 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
+ * @return array Array of OrderProduct 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(OrderProductPeer::DATABASE_NAME);
+ }
+
+ OrderProductPeer::addSelectColumns($criteria);
+ $startcol = OrderProductPeer::NUM_HYDRATE_COLUMNS;
+ OrderPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderProductPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderProductPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = OrderProductPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderProductPeer::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 (OrderProduct) to $obj2 (Order)
+ $obj2->addOrderProduct($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(OrderProductPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ OrderProductPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderProductPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(OrderProductPeer::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 OrderProduct 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 OrderProduct 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(OrderProductPeer::DATABASE_NAME);
+ }
+
+ OrderProductPeer::addSelectColumns($criteria);
+ $startcol2 = OrderProductPeer::NUM_HYDRATE_COLUMNS;
+
+ OrderPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = OrderProductPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = OrderProductPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = OrderProductPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ OrderProductPeer::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 (OrderProduct) to the collection in $obj2 (Order)
+ $obj2->addOrderProduct($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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(OrderProductPeer::DATABASE_NAME)->getTable(OrderProductPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseOrderProductPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseOrderProductPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderProductTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return OrderProductPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderProduct or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderProduct object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from OrderProduct object
+ }
+
+ if ($criteria->containsKey(OrderProductPeer::ID) && $criteria->keyContainsValue(OrderProductPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderProductPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a OrderProduct or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderProduct object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(OrderProductPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(OrderProductPeer::ID);
+ $value = $criteria->remove(OrderProductPeer::ID);
+ if ($value) {
+ $selectCriteria->add(OrderProductPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(OrderProductPeer::TABLE_NAME);
+ }
+
+ } else { // $values is OrderProduct object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(OrderProductPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the order_product table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ OrderProductPeer::clearInstancePool();
+ OrderProductPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderProduct or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderProduct object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(OrderProductPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ OrderProductPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given OrderProduct object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param OrderProduct $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(OrderProductPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(OrderProductPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(OrderProductPeer::DATABASE_NAME, OrderProductPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return OrderProduct
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = OrderProductPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(OrderProductPeer::DATABASE_NAME);
+ $criteria->add(OrderProductPeer::ID, $pk);
+
+ $v = OrderProductPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return OrderProduct[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(OrderProductPeer::DATABASE_NAME);
+ $criteria->add(OrderProductPeer::ID, $pks, Criteria::IN);
+ $objs = OrderProductPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseOrderProductPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseOrderProductPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php
new file mode 100644
index 000000000..4c741ee18
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php
@@ -0,0 +1,872 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return OrderProduct|OrderProduct[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderProductPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderProduct A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `ORDER_ID`, `PRODUCT_REF`, `TITLE`, `DESCRIPTION`, `CHAPO`, `QUANTITY`, `PRICE`, `TAX`, `PARENT`, `CREATED_AT`, `UPDATED_AT` FROM `order_product` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new OrderProduct();
+ $obj->hydrate($row);
+ OrderProductPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderProduct|OrderProduct[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|OrderProduct[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderProductPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderProductPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderId(1234); // WHERE order_id = 1234
+ * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
+ * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
+ *
+ *
+ * @see filterByOrder()
+ *
+ * @param mixed $orderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByOrderId($orderId = null, $comparison = null)
+ {
+ if (is_array($orderId)) {
+ $useMinMax = false;
+ if (isset($orderId['min'])) {
+ $this->addUsingAlias(OrderProductPeer::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderId['max'])) {
+ $this->addUsingAlias(OrderProductPeer::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::ORDER_ID, $orderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductRef('fooValue'); // WHERE product_ref = 'fooValue'
+ * $query->filterByProductRef('%fooValue%'); // WHERE product_ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $productRef The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByProductRef($productRef = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($productRef)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $productRef)) {
+ $productRef = str_replace('*', '%', $productRef);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::PRODUCT_REF, $productRef, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the quantity column
+ *
+ * Example usage:
+ *
+ * $query->filterByQuantity(1234); // WHERE quantity = 1234
+ * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
+ * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
+ *
+ *
+ * @param mixed $quantity The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByQuantity($quantity = null, $comparison = null)
+ {
+ if (is_array($quantity)) {
+ $useMinMax = false;
+ if (isset($quantity['min'])) {
+ $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($quantity['max'])) {
+ $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity, $comparison);
+ }
+
+ /**
+ * Filter the query on the price column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice(1234); // WHERE price = 1234
+ * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
+ * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
+ *
+ *
+ * @param mixed $price The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByPrice($price = null, $comparison = null)
+ {
+ if (is_array($price)) {
+ $useMinMax = false;
+ if (isset($price['min'])) {
+ $this->addUsingAlias(OrderProductPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price['max'])) {
+ $this->addUsingAlias(OrderProductPeer::PRICE, $price['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::PRICE, $price, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByTax(1234); // WHERE tax = 1234
+ * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34)
+ * $query->filterByTax(array('min' => 12)); // WHERE tax > 12
+ *
+ *
+ * @param mixed $tax The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByTax($tax = null, $comparison = null)
+ {
+ if (is_array($tax)) {
+ $useMinMax = false;
+ if (isset($tax['min'])) {
+ $this->addUsingAlias(OrderProductPeer::TAX, $tax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($tax['max'])) {
+ $this->addUsingAlias(OrderProductPeer::TAX, $tax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::TAX, $tax, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent column
+ *
+ * Example usage:
+ *
+ * $query->filterByParent(1234); // WHERE parent = 1234
+ * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
+ * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
+ *
+ *
+ * @param mixed $parent The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByParent($parent = null, $comparison = null)
+ {
+ if (is_array($parent)) {
+ $useMinMax = false;
+ if (isset($parent['min'])) {
+ $this->addUsingAlias(OrderProductPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(OrderProductPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::PARENT, $parent, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Order object
+ *
+ * @param Order|PropelObjectCollection $order The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof Order) {
+ return $this
+ ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->getId(), $comparison);
+ } elseif ($order instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order 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 joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // 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, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->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
+ *
+ * @param OrderProduct $orderProduct Object to remove from the list of results
+ *
+ * @return OrderProductQuery The current query, for fluid interface
+ */
+ public function prune($orderProduct = null)
+ {
+ if ($orderProduct) {
+ $this->addUsingAlias(OrderProductPeer::ID, $orderProduct->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderQuery.php b/core/lib/Thelia/Model/om/BaseOrderQuery.php
new file mode 100644
index 000000000..c691158b0
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderQuery.php
@@ -0,0 +1,1518 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Order|Order[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Order A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `REF`, `CUSTOMER_ID`, `ADDRESS_INVOICE`, `ADDRESS_DELIVERY`, `INVOICE_DATE`, `CURRENCY_ID`, `CURRENCY_RATE`, `TRANSACTION`, `DELIVERY_NUM`, `INVOICE`, `POSTAGE`, `PAYMENT`, `CARRIER`, `STATUS_ID`, `LANG`, `CREATED_AT`, `UPDATED_AT` FROM `order` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Order();
+ $obj->hydrate($row);
+ OrderPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Order|Order[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Order[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(OrderPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerId(1234); // WHERE customer_id = 1234
+ * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
+ * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
+ *
+ *
+ * @see filterByCustomer()
+ *
+ * @param mixed $customerId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByCustomerId($customerId = null, $comparison = null)
+ {
+ if (is_array($customerId)) {
+ $useMinMax = false;
+ if (isset($customerId['min'])) {
+ $this->addUsingAlias(OrderPeer::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerId['max'])) {
+ $this->addUsingAlias(OrderPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::CUSTOMER_ID, $customerId, $comparison);
+ }
+
+ /**
+ * Filter the query on the address_invoice column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddressInvoice(1234); // WHERE address_invoice = 1234
+ * $query->filterByAddressInvoice(array(12, 34)); // WHERE address_invoice IN (12, 34)
+ * $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice > 12
+ *
+ *
+ * @see filterByOrderAddressRelatedByAddressInvoice()
+ *
+ * @param mixed $addressInvoice The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByAddressInvoice($addressInvoice = null, $comparison = null)
+ {
+ if (is_array($addressInvoice)) {
+ $useMinMax = false;
+ if (isset($addressInvoice['min'])) {
+ $this->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $addressInvoice['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($addressInvoice['max'])) {
+ $this->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $addressInvoice['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $addressInvoice, $comparison);
+ }
+
+ /**
+ * Filter the query on the address_delivery column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddressDelivery(1234); // WHERE address_delivery = 1234
+ * $query->filterByAddressDelivery(array(12, 34)); // WHERE address_delivery IN (12, 34)
+ * $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery > 12
+ *
+ *
+ * @see filterByOrderAddressRelatedByAddressDelivery()
+ *
+ * @param mixed $addressDelivery The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByAddressDelivery($addressDelivery = null, $comparison = null)
+ {
+ if (is_array($addressDelivery)) {
+ $useMinMax = false;
+ if (isset($addressDelivery['min'])) {
+ $this->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $addressDelivery['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($addressDelivery['max'])) {
+ $this->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $addressDelivery['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $addressDelivery, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice_date column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiceDate('2011-03-14'); // WHERE invoice_date = '2011-03-14'
+ * $query->filterByInvoiceDate('now'); // WHERE invoice_date = '2011-03-14'
+ * $query->filterByInvoiceDate(array('max' => 'yesterday')); // WHERE invoice_date > '2011-03-13'
+ *
+ *
+ * @param mixed $invoiceDate The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByInvoiceDate($invoiceDate = null, $comparison = null)
+ {
+ if (is_array($invoiceDate)) {
+ $useMinMax = false;
+ if (isset($invoiceDate['min'])) {
+ $this->addUsingAlias(OrderPeer::INVOICE_DATE, $invoiceDate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($invoiceDate['max'])) {
+ $this->addUsingAlias(OrderPeer::INVOICE_DATE, $invoiceDate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::INVOICE_DATE, $invoiceDate, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyId(1234); // WHERE currency_id = 1234
+ * $query->filterByCurrencyId(array(12, 34)); // WHERE currency_id IN (12, 34)
+ * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id > 12
+ *
+ *
+ * @see filterByCurrency()
+ *
+ * @param mixed $currencyId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyId($currencyId = null, $comparison = null)
+ {
+ if (is_array($currencyId)) {
+ $useMinMax = false;
+ if (isset($currencyId['min'])) {
+ $this->addUsingAlias(OrderPeer::CURRENCY_ID, $currencyId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyId['max'])) {
+ $this->addUsingAlias(OrderPeer::CURRENCY_ID, $currencyId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::CURRENCY_ID, $currencyId, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_rate column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyRate(1234); // WHERE currency_rate = 1234
+ * $query->filterByCurrencyRate(array(12, 34)); // WHERE currency_rate IN (12, 34)
+ * $query->filterByCurrencyRate(array('min' => 12)); // WHERE currency_rate > 12
+ *
+ *
+ * @param mixed $currencyRate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyRate($currencyRate = null, $comparison = null)
+ {
+ if (is_array($currencyRate)) {
+ $useMinMax = false;
+ if (isset($currencyRate['min'])) {
+ $this->addUsingAlias(OrderPeer::CURRENCY_RATE, $currencyRate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyRate['max'])) {
+ $this->addUsingAlias(OrderPeer::CURRENCY_RATE, $currencyRate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::CURRENCY_RATE, $currencyRate, $comparison);
+ }
+
+ /**
+ * Filter the query on the transaction column
+ *
+ * Example usage:
+ *
+ * $query->filterByTransaction('fooValue'); // WHERE transaction = 'fooValue'
+ * $query->filterByTransaction('%fooValue%'); // WHERE transaction LIKE '%fooValue%'
+ *
+ *
+ * @param string $transaction The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByTransaction($transaction = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($transaction)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $transaction)) {
+ $transaction = str_replace('*', '%', $transaction);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::TRANSACTION, $transaction, $comparison);
+ }
+
+ /**
+ * Filter the query on the delivery_num column
+ *
+ * Example usage:
+ *
+ * $query->filterByDeliveryNum('fooValue'); // WHERE delivery_num = 'fooValue'
+ * $query->filterByDeliveryNum('%fooValue%'); // WHERE delivery_num LIKE '%fooValue%'
+ *
+ *
+ * @param string $deliveryNum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByDeliveryNum($deliveryNum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($deliveryNum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $deliveryNum)) {
+ $deliveryNum = str_replace('*', '%', $deliveryNum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::DELIVERY_NUM, $deliveryNum, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoice('fooValue'); // WHERE invoice = 'fooValue'
+ * $query->filterByInvoice('%fooValue%'); // WHERE invoice LIKE '%fooValue%'
+ *
+ *
+ * @param string $invoice The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByInvoice($invoice = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($invoice)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $invoice)) {
+ $invoice = str_replace('*', '%', $invoice);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::INVOICE, $invoice, $comparison);
+ }
+
+ /**
+ * Filter the query on the postage column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostage(1234); // WHERE postage = 1234
+ * $query->filterByPostage(array(12, 34)); // WHERE postage IN (12, 34)
+ * $query->filterByPostage(array('min' => 12)); // WHERE postage > 12
+ *
+ *
+ * @param mixed $postage The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByPostage($postage = null, $comparison = null)
+ {
+ if (is_array($postage)) {
+ $useMinMax = false;
+ if (isset($postage['min'])) {
+ $this->addUsingAlias(OrderPeer::POSTAGE, $postage['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($postage['max'])) {
+ $this->addUsingAlias(OrderPeer::POSTAGE, $postage['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::POSTAGE, $postage, $comparison);
+ }
+
+ /**
+ * Filter the query on the payment column
+ *
+ * Example usage:
+ *
+ * $query->filterByPayment('fooValue'); // WHERE payment = 'fooValue'
+ * $query->filterByPayment('%fooValue%'); // WHERE payment LIKE '%fooValue%'
+ *
+ *
+ * @param string $payment The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByPayment($payment = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($payment)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $payment)) {
+ $payment = str_replace('*', '%', $payment);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::PAYMENT, $payment, $comparison);
+ }
+
+ /**
+ * Filter the query on the carrier column
+ *
+ * Example usage:
+ *
+ * $query->filterByCarrier('fooValue'); // WHERE carrier = 'fooValue'
+ * $query->filterByCarrier('%fooValue%'); // WHERE carrier LIKE '%fooValue%'
+ *
+ *
+ * @param string $carrier The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByCarrier($carrier = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($carrier)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $carrier)) {
+ $carrier = str_replace('*', '%', $carrier);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::CARRIER, $carrier, $comparison);
+ }
+
+ /**
+ * Filter the query on the status_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByStatusId(1234); // WHERE status_id = 1234
+ * $query->filterByStatusId(array(12, 34)); // WHERE status_id IN (12, 34)
+ * $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12
+ *
+ *
+ * @see filterByOrderStatus()
+ *
+ * @param mixed $statusId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByStatusId($statusId = null, $comparison = null)
+ {
+ if (is_array($statusId)) {
+ $useMinMax = false;
+ if (isset($statusId['min'])) {
+ $this->addUsingAlias(OrderPeer::STATUS_ID, $statusId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($statusId['max'])) {
+ $this->addUsingAlias(OrderPeer::STATUS_ID, $statusId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::STATUS_ID, $statusId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Currency object
+ *
+ * @param Currency|PropelObjectCollection $currency The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCurrency($currency, $comparison = null)
+ {
+ if ($currency instanceof Currency) {
+ return $this
+ ->addUsingAlias(OrderPeer::CURRENCY_ID, $currency->getId(), $comparison);
+ } elseif ($currency instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderPeer::CURRENCY_ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCurrency() only accepts arguments of type Currency or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Currency 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 joinCurrency($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Currency');
+
+ // 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, 'Currency');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Currency relation Currency 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\CurrencyQuery A secondary query class using the current class as primary query
+ */
+ public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCurrency($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Currency', '\Thelia\Model\CurrencyQuery');
+ }
+
+ /**
+ * Filter the query by a related Customer object
+ *
+ * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCustomer($customer, $comparison = null)
+ {
+ if ($customer instanceof Customer) {
+ return $this
+ ->addUsingAlias(OrderPeer::CUSTOMER_ID, $customer->getId(), $comparison);
+ } elseif ($customer instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Customer 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 joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Customer');
+
+ // 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, 'Customer');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Customer relation Customer 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\CustomerQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCustomer($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
+ }
+
+ /**
+ * Filter the query by a related OrderAddress object
+ *
+ * @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 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
+ ->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderAddressRelatedByAddressInvoice() only accepts arguments of type OrderAddress or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 joinOrderAddressRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressInvoice');
+
+ // 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, 'OrderAddressRelatedByAddressInvoice');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderAddressRelatedByAddressInvoice relation OrderAddress 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\OrderAddressQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderAddressRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->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(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 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
+ ->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderAddressRelatedByAddressDelivery() only accepts arguments of type OrderAddress or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 joinOrderAddressRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressDelivery');
+
+ // 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, 'OrderAddressRelatedByAddressDelivery');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderAddressRelatedByAddressDelivery relation OrderAddress 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\OrderAddressQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderAddressRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->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(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 filterByOrderStatus($orderStatus, $comparison = null)
+ {
+ if ($orderStatus instanceof OrderStatus) {
+ return $this
+ ->addUsingAlias(OrderPeer::STATUS_ID, $orderStatus->getId(), $comparison);
+ } elseif ($orderStatus instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderPeer::STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderStatus() only accepts arguments of type OrderStatus or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderStatus 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 joinOrderStatus($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderStatus');
+
+ // 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, 'OrderStatus');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderStatus relation OrderStatus 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\OrderStatusQuery A secondary query class using the current class as primary query
+ */
+ 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
+ *
+ * @param Order $order Object to remove from the list of results
+ *
+ * @return OrderQuery The current query, for fluid interface
+ */
+ public function prune($order = null)
+ {
+ if ($order) {
+ $this->addUsingAlias(OrderPeer::ID, $order->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatus.php b/core/lib/Thelia/Model/om/BaseOrderStatus.php
new file mode 100644
index 000000000..62c14b0fe
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderStatus.php
@@ -0,0 +1,1660 @@
+id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return OrderStatus The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderStatusPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return OrderStatus The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = OrderStatusPeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderStatus The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderStatusPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderStatus The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderStatusPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = OrderStatusPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating OrderStatus object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = OrderStatusPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collOrders = null;
+
+ $this->collOrderStatusDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = OrderStatusQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderStatusPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderStatusPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderStatusPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderStatusPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(OrderStatusPeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(OrderStatusPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(OrderStatusPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `order_status` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderStatus'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderStatus'][$this->getPrimaryKey()] = true;
+ $keys = OrderStatusPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrderStatusDescs) {
+ $result['OrderStatusDescs'] = $this->collOrderStatusDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = OrderStatusPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderStatusPeer::ID)) $criteria->add(OrderStatusPeer::ID, $this->id);
+ if ($this->isColumnModified(OrderStatusPeer::CODE)) $criteria->add(OrderStatusPeer::CODE, $this->code);
+ if ($this->isColumnModified(OrderStatusPeer::CREATED_AT)) $criteria->add(OrderStatusPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderStatusPeer::UPDATED_AT)) $criteria->add(OrderStatusPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME);
+ $criteria->add(OrderStatusPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of OrderStatus (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ 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
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return OrderStatus Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return OrderStatusPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new OrderStatusPeer();
+ }
+
+ 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.
+ *
+ * @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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param Order $order The order object to add.
+ */
+ protected function doAddOrder($order)
+ {
+ $this->collOrders[]= $order;
+ $order->setOrderStatus($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->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.
+ *
+ * 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 getOrderStatusDescs($criteria = null, PropelPDO $con = 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 {
+ return count($this->collOrderStatusDescs);
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * @param OrderStatusDesc $orderStatusDesc The orderStatusDesc object to remove.
+ */
+ public function removeOrderStatusDesc($orderStatusDesc)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ if ($this->collOrders instanceof PropelCollection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
+ if ($this->collOrderStatusDescs instanceof PropelCollection) {
+ $this->collOrderStatusDescs->clearIterator();
+ }
+ $this->collOrderStatusDescs = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderStatusPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php b/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php
new file mode 100644
index 000000000..63d7b25f6
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php
@@ -0,0 +1,1320 @@
+id;
+ }
+
+ /**
+ * Get the [status_id] column value.
+ *
+ * @return int
+ */
+ public function getStatusId()
+ {
+ return $this->status_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return OrderStatusDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderStatusDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [status_id] column.
+ *
+ * @param int $v new value
+ * @return OrderStatusDesc The current object (for fluent API support)
+ */
+ public function setStatusId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->status_id !== $v) {
+ $this->status_id = $v;
+ $this->modifiedColumns[] = OrderStatusDescPeer::STATUS_ID;
+ }
+
+ if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) {
+ $this->aOrderStatus = null;
+ }
+
+
+ return $this;
+ } // setStatusId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return OrderStatusDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = OrderStatusDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return OrderStatusDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = OrderStatusDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return OrderStatusDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = OrderStatusDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return OrderStatusDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = OrderStatusDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderStatusDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderStatusDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return OrderStatusDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = OrderStatusDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->status_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = OrderStatusDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating OrderStatusDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aOrderStatus !== null && $this->status_id !== $this->aOrderStatus->getId()) {
+ $this->aOrderStatus = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = OrderStatusDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrderStatus = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = OrderStatusDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderStatusDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderStatusDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderStatusDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderStatusDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(OrderStatusDescPeer::STATUS_ID)) {
+ $modifiedColumns[':p' . $index++] = '`STATUS_ID`';
+ }
+ if ($this->isColumnModified(OrderStatusDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(OrderStatusDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(OrderStatusDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(OrderStatusDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(OrderStatusDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(OrderStatusDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `order_status_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`STATUS_ID`':
+ $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderStatusDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getStatusId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderStatusDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderStatusDesc'][$this->getPrimaryKey()] = true;
+ $keys = OrderStatusDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getStatusId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrderStatus) {
+ $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = OrderStatusDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setStatusId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = OrderStatusDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setStatusId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderStatusDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderStatusDescPeer::ID)) $criteria->add(OrderStatusDescPeer::ID, $this->id);
+ if ($this->isColumnModified(OrderStatusDescPeer::STATUS_ID)) $criteria->add(OrderStatusDescPeer::STATUS_ID, $this->status_id);
+ if ($this->isColumnModified(OrderStatusDescPeer::LANG)) $criteria->add(OrderStatusDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(OrderStatusDescPeer::TITLE)) $criteria->add(OrderStatusDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(OrderStatusDescPeer::DESCRIPTION)) $criteria->add(OrderStatusDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(OrderStatusDescPeer::CHAPO)) $criteria->add(OrderStatusDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(OrderStatusDescPeer::CREATED_AT)) $criteria->add(OrderStatusDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderStatusDescPeer::UPDATED_AT)) $criteria->add(OrderStatusDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderStatusDescPeer::DATABASE_NAME);
+ $criteria->add(OrderStatusDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of OrderStatusDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setStatusId($this->getStatusId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return OrderStatusDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return OrderStatusDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new OrderStatusDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a OrderStatus object.
+ *
+ * @param OrderStatus $v
+ * @return OrderStatusDesc 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->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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->status_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aOrderStatus = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderStatusDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusDescPeer.php b/core/lib/Thelia/Model/om/BaseOrderStatusDescPeer.php
new file mode 100644
index 000000000..963cda92b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusDescPeer.php
@@ -0,0 +1,1037 @@
+ array ('Id', 'StatusId', 'Lang', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'statusId', 'lang', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (OrderStatusDescPeer::ID, OrderStatusDescPeer::STATUS_ID, OrderStatusDescPeer::LANG, OrderStatusDescPeer::TITLE, OrderStatusDescPeer::DESCRIPTION, OrderStatusDescPeer::CHAPO, OrderStatusDescPeer::CREATED_AT, OrderStatusDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STATUS_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'status_id', 'lang', 'title', 'description', 'chapo', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. OrderStatusDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'StatusId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'statusId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (OrderStatusDescPeer::ID => 0, OrderStatusDescPeer::STATUS_ID => 1, OrderStatusDescPeer::LANG => 2, OrderStatusDescPeer::TITLE => 3, OrderStatusDescPeer::DESCRIPTION => 4, OrderStatusDescPeer::CHAPO => 5, OrderStatusDescPeer::CREATED_AT => 6, OrderStatusDescPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STATUS_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'status_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = OrderStatusDescPeer::getFieldNames($toType);
+ $key = isset(OrderStatusDescPeer::$fieldKeys[$fromType][$name]) ? OrderStatusDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderStatusDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, OrderStatusDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return OrderStatusDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. OrderStatusDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(OrderStatusDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderStatusDescPeer::ID);
+ $criteria->addSelectColumn(OrderStatusDescPeer::STATUS_ID);
+ $criteria->addSelectColumn(OrderStatusDescPeer::LANG);
+ $criteria->addSelectColumn(OrderStatusDescPeer::TITLE);
+ $criteria->addSelectColumn(OrderStatusDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(OrderStatusDescPeer::CHAPO);
+ $criteria->addSelectColumn(OrderStatusDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(OrderStatusDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.STATUS_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return OrderStatusDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = OrderStatusDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return OrderStatusDescPeer::populateObjects(OrderStatusDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ OrderStatusDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param OrderStatusDesc $obj A OrderStatusDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ OrderStatusDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A OrderStatusDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof OrderStatusDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderStatusDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(OrderStatusDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return OrderStatusDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(OrderStatusDescPeer::$instances[$key])) {
+ return OrderStatusDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ OrderStatusDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to order_status_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = OrderStatusDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = OrderStatusDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = OrderStatusDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderStatusDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderStatusDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = OrderStatusDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = OrderStatusDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + OrderStatusDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderStatusDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ OrderStatusDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(OrderStatusDescPeer::DATABASE_NAME)->getTable(OrderStatusDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseOrderStatusDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseOrderStatusDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderStatusDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return OrderStatusDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderStatusDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderStatusDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from OrderStatusDesc object
+ }
+
+ if ($criteria->containsKey(OrderStatusDescPeer::ID) && $criteria->keyContainsValue(OrderStatusDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderStatusDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a OrderStatusDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderStatusDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(OrderStatusDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(OrderStatusDescPeer::ID);
+ $value = $criteria->remove(OrderStatusDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(OrderStatusDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(OrderStatusDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is OrderStatusDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the order_status_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ OrderStatusDescPeer::clearInstancePool();
+ OrderStatusDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderStatusDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderStatusDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(OrderStatusDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ OrderStatusDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given OrderStatusDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param OrderStatusDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(OrderStatusDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(OrderStatusDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(OrderStatusDescPeer::DATABASE_NAME, OrderStatusDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return OrderStatusDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = OrderStatusDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(OrderStatusDescPeer::DATABASE_NAME);
+ $criteria->add(OrderStatusDescPeer::ID, $pk);
+
+ $v = OrderStatusDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return OrderStatusDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(OrderStatusDescPeer::DATABASE_NAME);
+ $criteria->add(OrderStatusDescPeer::ID, $pks, Criteria::IN);
+ $objs = OrderStatusDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseOrderStatusDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseOrderStatusDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php
new file mode 100644
index 000000000..5ad88bed4
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php
@@ -0,0 +1,613 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return OrderStatusDesc|OrderStatusDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderStatusDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderStatusDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `STATUS_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `order_status_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new OrderStatusDesc();
+ $obj->hydrate($row);
+ OrderStatusDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderStatusDesc|OrderStatusDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|OrderStatusDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderStatusDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderStatusDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(OrderStatusDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the status_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByStatusId(1234); // WHERE status_id = 1234
+ * $query->filterByStatusId(array(12, 34)); // WHERE status_id IN (12, 34)
+ * $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12
+ *
+ *
+ * @see filterByOrderStatus()
+ *
+ * @param mixed $statusId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByStatusId($statusId = null, $comparison = null)
+ {
+ if (is_array($statusId)) {
+ $useMinMax = false;
+ if (isset($statusId['min'])) {
+ $this->addUsingAlias(OrderStatusDescPeer::STATUS_ID, $statusId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($statusId['max'])) {
+ $this->addUsingAlias(OrderStatusDescPeer::STATUS_ID, $statusId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusDescPeer::STATUS_ID, $statusId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderStatusDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderStatusDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderStatusDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderStatusDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related OrderStatus object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrderStatus($orderStatus, $comparison = null)
+ {
+ if ($orderStatus instanceof OrderStatus) {
+ return $this
+ ->addUsingAlias(OrderStatusDescPeer::STATUS_ID, $orderStatus->getId(), $comparison);
+ } elseif ($orderStatus instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderStatusDescPeer::STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderStatus() only accepts arguments of type OrderStatus or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderStatus relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function joinOrderStatus($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderStatus');
+
+ // 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, 'OrderStatus');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderStatus relation OrderStatus 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\OrderStatusQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderStatus($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\Thelia\Model\OrderStatusQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param OrderStatusDesc $orderStatusDesc Object to remove from the list of results
+ *
+ * @return OrderStatusDescQuery The current query, for fluid interface
+ */
+ public function prune($orderStatusDesc = null)
+ {
+ if ($orderStatusDesc) {
+ $this->addUsingAlias(OrderStatusDescPeer::ID, $orderStatusDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php b/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php
new file mode 100644
index 000000000..27e60e8a1
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php
@@ -0,0 +1,786 @@
+ array ('Id', 'Code', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (OrderStatusPeer::ID, OrderStatusPeer::CODE, OrderStatusPeer::CREATED_AT, OrderStatusPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. OrderStatusPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ BasePeer::TYPE_COLNAME => array (OrderStatusPeer::ID => 0, OrderStatusPeer::CODE => 1, OrderStatusPeer::CREATED_AT => 2, OrderStatusPeer::UPDATED_AT => 3, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = OrderStatusPeer::getFieldNames($toType);
+ $key = isset(OrderStatusPeer::$fieldKeys[$fromType][$name]) ? OrderStatusPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderStatusPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, OrderStatusPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return OrderStatusPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. OrderStatusPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(OrderStatusPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderStatusPeer::ID);
+ $criteria->addSelectColumn(OrderStatusPeer::CODE);
+ $criteria->addSelectColumn(OrderStatusPeer::CREATED_AT);
+ $criteria->addSelectColumn(OrderStatusPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(OrderStatusPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return OrderStatus
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = OrderStatusPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return OrderStatusPeer::populateObjects(OrderStatusPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ OrderStatusPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param OrderStatus $obj A OrderStatus object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ OrderStatusPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A OrderStatus object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof OrderStatus) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderStatus object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(OrderStatusPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return OrderStatus Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(OrderStatusPeer::$instances[$key])) {
+ return OrderStatusPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ OrderStatusPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to order_status
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = OrderStatusPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = OrderStatusPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = OrderStatusPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderStatusPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderStatus object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = OrderStatusPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderStatusPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ OrderStatusPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(OrderStatusPeer::DATABASE_NAME)->getTable(OrderStatusPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseOrderStatusPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseOrderStatusPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderStatusTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return OrderStatusPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderStatus or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderStatus object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from OrderStatus object
+ }
+
+ if ($criteria->containsKey(OrderStatusPeer::ID) && $criteria->keyContainsValue(OrderStatusPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderStatusPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a OrderStatus or Criteria object.
+ *
+ * @param mixed $values Criteria or OrderStatus object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(OrderStatusPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(OrderStatusPeer::ID);
+ $value = $criteria->remove(OrderStatusPeer::ID);
+ if ($value) {
+ $selectCriteria->add(OrderStatusPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(OrderStatusPeer::TABLE_NAME);
+ }
+
+ } else { // $values is OrderStatus object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the order_status table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(OrderStatusPeer::TABLE_NAME, $con, OrderStatusPeer::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
+ // instances get re-added by the select statement contained therein).
+ OrderStatusPeer::clearInstancePool();
+ OrderStatusPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderStatus or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderStatus object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ OrderStatusPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof OrderStatus) { // it's a model object
+ // invalidate the cache for this single object
+ OrderStatusPeer::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(OrderStatusPeer::DATABASE_NAME);
+ $criteria->add(OrderStatusPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ OrderStatusPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ OrderStatusPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given OrderStatus object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param OrderStatus $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(OrderStatusPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(OrderStatusPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(OrderStatusPeer::DATABASE_NAME, OrderStatusPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return OrderStatus
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = OrderStatusPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME);
+ $criteria->add(OrderStatusPeer::ID, $pk);
+
+ $v = OrderStatusPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return OrderStatus[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME);
+ $criteria->add(OrderStatusPeer::ID, $pks, Criteria::IN);
+ $objs = OrderStatusPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseOrderStatusPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseOrderStatusPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php
new file mode 100644
index 000000000..9d3a2d1b7
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php
@@ -0,0 +1,544 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return OrderStatus|OrderStatus[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderStatusPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderStatus A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CODE`, `CREATED_AT`, `UPDATED_AT` FROM `order_status` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new OrderStatus();
+ $obj->hydrate($row);
+ OrderStatusPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return OrderStatus|OrderStatus[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|OrderStatus[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderStatusPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderStatusPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(OrderStatusPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusPeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Order object
+ *
+ * @param Order|PropelObjectCollection $order the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof Order) {
+ return $this
+ ->addUsingAlias(OrderStatusPeer::ID, $order->getStatusId(), $comparison);
+ } elseif ($order instanceof PropelObjectCollection) {
+ return $this
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // 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, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Filter the query by a related OrderStatusDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByOrderStatusDesc($orderStatusDesc, $comparison = null)
+ {
+ if ($orderStatusDesc instanceof OrderStatusDesc) {
+ return $this
+ ->addUsingAlias(OrderStatusPeer::ID, $orderStatusDesc->getStatusId(), $comparison);
+ } elseif ($orderStatusDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useOrderStatusDescQuery()
+ ->filterByPrimaryKeys($orderStatusDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderStatusDesc() only accepts arguments of type OrderStatusDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderStatusDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function joinOrderStatusDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderStatusDesc');
+
+ // 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, 'OrderStatusDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderStatusDesc relation OrderStatusDesc 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\OrderStatusDescQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderStatusDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderStatusDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderStatusDesc', '\Thelia\Model\OrderStatusDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param OrderStatus $orderStatus Object to remove from the list of results
+ *
+ * @return OrderStatusQuery The current query, for fluid interface
+ */
+ public function prune($orderStatus = null)
+ {
+ if ($orderStatus) {
+ $this->addUsingAlias(OrderStatusPeer::ID, $orderStatus->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseProduct.php b/core/lib/Thelia/Model/om/BaseProduct.php
new file mode 100644
index 000000000..bd38bec51
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProduct.php
@@ -0,0 +1,4777 @@
+newness = 0;
+ $this->promo = 0;
+ $this->quantity = 0;
+ $this->visible = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseProduct object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Get the [tax_rule_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxRuleId()
+ {
+ return $this->tax_rule_id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+ return $this->ref;
+ }
+
+ /**
+ * Get the [price] column value.
+ *
+ * @return double
+ */
+ public function getPrice()
+ {
+ return $this->price;
+ }
+
+ /**
+ * Get the [price2] column value.
+ *
+ * @return double
+ */
+ public function getPrice2()
+ {
+ return $this->price2;
+ }
+
+ /**
+ * Get the [ecotax] column value.
+ *
+ * @return double
+ */
+ public function getEcotax()
+ {
+ return $this->ecotax;
+ }
+
+ /**
+ * Get the [newness] column value.
+ *
+ * @return int
+ */
+ public function getNewness()
+ {
+ return $this->newness;
+ }
+
+ /**
+ * Get the [promo] column value.
+ *
+ * @return int
+ */
+ public function getPromo()
+ {
+ return $this->promo;
+ }
+
+ /**
+ * Get the [quantity] column value.
+ *
+ * @return int
+ */
+ public function getQuantity()
+ {
+ return $this->quantity;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+ return $this->visible;
+ }
+
+ /**
+ * Get the [weight] column value.
+ *
+ * @return double
+ */
+ public function getWeight()
+ {
+ return $this->weight;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ProductPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [tax_rule_id] column.
+ *
+ * @param int $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setTaxRuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_rule_id !== $v) {
+ $this->tax_rule_id = $v;
+ $this->modifiedColumns[] = ProductPeer::TAX_RULE_ID;
+ }
+
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
+
+ return $this;
+ } // setTaxRuleId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = ProductPeer::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [price] column.
+ *
+ * @param double $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setPrice($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->price !== $v) {
+ $this->price = $v;
+ $this->modifiedColumns[] = ProductPeer::PRICE;
+ }
+
+
+ return $this;
+ } // setPrice()
+
+ /**
+ * Set the value of [price2] column.
+ *
+ * @param double $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setPrice2($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->price2 !== $v) {
+ $this->price2 = $v;
+ $this->modifiedColumns[] = ProductPeer::PRICE2;
+ }
+
+
+ return $this;
+ } // setPrice2()
+
+ /**
+ * Set the value of [ecotax] column.
+ *
+ * @param double $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setEcotax($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->ecotax !== $v) {
+ $this->ecotax = $v;
+ $this->modifiedColumns[] = ProductPeer::ECOTAX;
+ }
+
+
+ return $this;
+ } // setEcotax()
+
+ /**
+ * Set the value of [newness] column.
+ *
+ * @param int $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setNewness($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->newness !== $v) {
+ $this->newness = $v;
+ $this->modifiedColumns[] = ProductPeer::NEWNESS;
+ }
+
+
+ return $this;
+ } // setNewness()
+
+ /**
+ * Set the value of [promo] column.
+ *
+ * @param int $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setPromo($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->promo !== $v) {
+ $this->promo = $v;
+ $this->modifiedColumns[] = ProductPeer::PROMO;
+ }
+
+
+ return $this;
+ } // setPromo()
+
+ /**
+ * Set the value of [quantity] column.
+ *
+ * @param int $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setQuantity($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->quantity !== $v) {
+ $this->quantity = $v;
+ $this->modifiedColumns[] = ProductPeer::QUANTITY;
+ }
+
+
+ return $this;
+ } // setQuantity()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = ProductPeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [weight] column.
+ *
+ * @param double $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setWeight($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->weight !== $v) {
+ $this->weight = $v;
+ $this->modifiedColumns[] = ProductPeer::WEIGHT;
+ }
+
+
+ return $this;
+ } // setWeight()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ProductPeer::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Product The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ProductPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Product The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ProductPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->newness !== 0) {
+ return false;
+ }
+
+ if ($this->promo !== 0) {
+ return false;
+ }
+
+ if ($this->quantity !== 0) {
+ return false;
+ }
+
+ if ($this->visible !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->tax_rule_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->ref = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->price = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null;
+ $this->price2 = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null;
+ $this->ecotax = ($row[$startcol + 5] !== null) ? (double) $row[$startcol + 5] : null;
+ $this->newness = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
+ $this->promo = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
+ $this->quantity = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
+ $this->visible = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
+ $this->weight = ($row[$startcol + 10] !== null) ? (double) $row[$startcol + 10] : null;
+ $this->position = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
+ $this->created_at = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
+ $this->updated_at = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 14; // 14 = ProductPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Product object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ProductPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $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)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ProductQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ProductPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->accessorysRelatedByProductIdScheduledForDeletion !== null) {
+ if (!$this->accessorysRelatedByProductIdScheduledForDeletion->isEmpty()) {
+ AccessoryQuery::create()
+ ->filterByPrimaryKeys($this->accessorysRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->accessorysRelatedByProductIdScheduledForDeletion = null;
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ProductPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ProductPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ProductPeer::TAX_RULE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`';
+ }
+ if ($this->isColumnModified(ProductPeer::REF)) {
+ $modifiedColumns[':p' . $index++] = '`REF`';
+ }
+ if ($this->isColumnModified(ProductPeer::PRICE)) {
+ $modifiedColumns[':p' . $index++] = '`PRICE`';
+ }
+ if ($this->isColumnModified(ProductPeer::PRICE2)) {
+ $modifiedColumns[':p' . $index++] = '`PRICE2`';
+ }
+ if ($this->isColumnModified(ProductPeer::ECOTAX)) {
+ $modifiedColumns[':p' . $index++] = '`ECOTAX`';
+ }
+ if ($this->isColumnModified(ProductPeer::NEWNESS)) {
+ $modifiedColumns[':p' . $index++] = '`NEWNESS`';
+ }
+ if ($this->isColumnModified(ProductPeer::PROMO)) {
+ $modifiedColumns[':p' . $index++] = '`PROMO`';
+ }
+ if ($this->isColumnModified(ProductPeer::QUANTITY)) {
+ $modifiedColumns[':p' . $index++] = '`QUANTITY`';
+ }
+ if ($this->isColumnModified(ProductPeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(ProductPeer::WEIGHT)) {
+ $modifiedColumns[':p' . $index++] = '`WEIGHT`';
+ }
+ if ($this->isColumnModified(ProductPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(ProductPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ProductPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `product` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`TAX_RULE_ID`':
+ $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
+ break;
+ case '`REF`':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case '`PRICE`':
+ $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
+ break;
+ case '`PRICE2`':
+ $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR);
+ break;
+ case '`ECOTAX`':
+ $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR);
+ break;
+ case '`NEWNESS`':
+ $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT);
+ break;
+ case '`PROMO`':
+ $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT);
+ break;
+ case '`QUANTITY`':
+ $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT);
+ break;
+ case '`VISIBLE`':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case '`WEIGHT`':
+ $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR);
+ break;
+ case '`POSITION`':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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 = ProductPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ 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());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getTaxRuleId();
+ break;
+ case 2:
+ return $this->getRef();
+ break;
+ case 3:
+ return $this->getPrice();
+ break;
+ case 4:
+ return $this->getPrice2();
+ break;
+ case 5:
+ return $this->getEcotax();
+ break;
+ case 6:
+ return $this->getNewness();
+ break;
+ case 7:
+ return $this->getPromo();
+ break;
+ case 8:
+ return $this->getQuantity();
+ break;
+ case 9:
+ return $this->getVisible();
+ break;
+ case 10:
+ return $this->getWeight();
+ break;
+ case 11:
+ return $this->getPosition();
+ break;
+ case 12:
+ return $this->getCreatedAt();
+ break;
+ case 13:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Product'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Product'][$this->getPrimaryKey()] = true;
+ $keys = ProductPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTaxRuleId(),
+ $keys[2] => $this->getRef(),
+ $keys[3] => $this->getPrice(),
+ $keys[4] => $this->getPrice2(),
+ $keys[5] => $this->getEcotax(),
+ $keys[6] => $this->getNewness(),
+ $keys[7] => $this->getPromo(),
+ $keys[8] => $this->getQuantity(),
+ $keys[9] => $this->getVisible(),
+ $keys[10] => $this->getWeight(),
+ $keys[11] => $this->getPosition(),
+ $keys[12] => $this->getCreatedAt(),
+ $keys[13] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collAccessorysRelatedByProductId) {
+ $result['AccessorysRelatedByProductId'] = $this->collAccessorysRelatedByProductId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAccessorysRelatedByAccessory) {
+ $result['AccessorysRelatedByAccessory'] = $this->collAccessorysRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collProductCategorys) {
+ $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collProductDescs) {
+ $result['ProductDescs'] = $this->collProductDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collStocks) {
+ $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setTaxRuleId($value);
+ break;
+ case 2:
+ $this->setRef($value);
+ break;
+ case 3:
+ $this->setPrice($value);
+ break;
+ case 4:
+ $this->setPrice2($value);
+ break;
+ case 5:
+ $this->setEcotax($value);
+ break;
+ case 6:
+ $this->setNewness($value);
+ break;
+ case 7:
+ $this->setPromo($value);
+ break;
+ case 8:
+ $this->setQuantity($value);
+ break;
+ case 9:
+ $this->setVisible($value);
+ break;
+ case 10:
+ $this->setWeight($value);
+ break;
+ case 11:
+ $this->setPosition($value);
+ break;
+ case 12:
+ $this->setCreatedAt($value);
+ break;
+ case 13:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ProductPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPrice2($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setEcotax($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setNewness($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setPromo($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ProductPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ProductPeer::ID)) $criteria->add(ProductPeer::ID, $this->id);
+ if ($this->isColumnModified(ProductPeer::TAX_RULE_ID)) $criteria->add(ProductPeer::TAX_RULE_ID, $this->tax_rule_id);
+ if ($this->isColumnModified(ProductPeer::REF)) $criteria->add(ProductPeer::REF, $this->ref);
+ if ($this->isColumnModified(ProductPeer::PRICE)) $criteria->add(ProductPeer::PRICE, $this->price);
+ if ($this->isColumnModified(ProductPeer::PRICE2)) $criteria->add(ProductPeer::PRICE2, $this->price2);
+ if ($this->isColumnModified(ProductPeer::ECOTAX)) $criteria->add(ProductPeer::ECOTAX, $this->ecotax);
+ if ($this->isColumnModified(ProductPeer::NEWNESS)) $criteria->add(ProductPeer::NEWNESS, $this->newness);
+ if ($this->isColumnModified(ProductPeer::PROMO)) $criteria->add(ProductPeer::PROMO, $this->promo);
+ if ($this->isColumnModified(ProductPeer::QUANTITY)) $criteria->add(ProductPeer::QUANTITY, $this->quantity);
+ if ($this->isColumnModified(ProductPeer::VISIBLE)) $criteria->add(ProductPeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(ProductPeer::WEIGHT)) $criteria->add(ProductPeer::WEIGHT, $this->weight);
+ if ($this->isColumnModified(ProductPeer::POSITION)) $criteria->add(ProductPeer::POSITION, $this->position);
+ if ($this->isColumnModified(ProductPeer::CREATED_AT)) $criteria->add(ProductPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ProductPeer::UPDATED_AT)) $criteria->add(ProductPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ProductPeer::DATABASE_NAME);
+ $criteria->add(ProductPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Product (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTaxRuleId($this->getTaxRuleId());
+ $copyObj->setRef($this->getRef());
+ $copyObj->setPrice($this->getPrice());
+ $copyObj->setPrice2($this->getPrice2());
+ $copyObj->setEcotax($this->getEcotax());
+ $copyObj->setNewness($this->getNewness());
+ $copyObj->setPromo($this->getPromo());
+ $copyObj->setQuantity($this->getQuantity());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setWeight($this->getWeight());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ 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));
+ }
+ }
+
+ foreach ($this->getContentAssocs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentAssoc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDocuments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocument($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureProds() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureProd($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getImages() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImage($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getProductCategorys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProductCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getProductDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProductDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getRewritings() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addRewriting($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getStocks() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addStock($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Product Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ProductPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ProductPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a TaxRule object.
+ *
+ * @param TaxRule $v
+ * @return Product The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTaxRule(TaxRule $v = null)
+ {
+ 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->addProduct($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->addProducts($this);
+ */
+ }
+
+ return $this->aTaxRule;
+ }
+
+
+ /**
+ * 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 string $relationName The name of the relation to initialize
+ * @return void
+ */
+ 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();
+ }
+ }
+
+ /**
+ * 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 PropelObjectCollection|Accessory[] List of Accessory objects
+ * @throws PropelException
+ */
+ 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);
+
+ 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->collAccessorysRelatedByProductId;
+ }
+
+ /**
+ * 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 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 countAccessorysRelatedByProductId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $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();
+ }
+
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->tax_rule_id = null;
+ $this->ref = null;
+ $this->price = null;
+ $this->price2 = null;
+ $this->ecotax = null;
+ $this->newness = null;
+ $this->promo = null;
+ $this->quantity = null;
+ $this->visible = null;
+ $this->weight = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($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->collAccessorysRelatedByProductId instanceof PropelCollection) {
+ $this->collAccessorysRelatedByProductId->clearIterator();
+ }
+ $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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ProductPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseProductCategory.php b/core/lib/Thelia/Model/om/BaseProductCategory.php
new file mode 100644
index 000000000..8814b09b1
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductCategory.php
@@ -0,0 +1,1009 @@
+product_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+ return $this->category_id;
+ }
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return ProductCategory The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = ProductCategoryPeer::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return ProductCategory The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = ProductCategoryPeer::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->product_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->category_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 2; // 2 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ProductCategory object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ProductCategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ProductCategoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ProductCategoryPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ProductCategoryPeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(ProductCategoryPeer::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `product_category` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`CATEGORY_ID`':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ProductCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getProductId();
+ break;
+ case 1:
+ return $this->getCategoryId();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ProductCategory'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ProductCategory'][serialize($this->getPrimaryKey())] = true;
+ $keys = ProductCategoryPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getProductId(),
+ $keys[1] => $this->getCategoryId(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ProductCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setProductId($value);
+ break;
+ case 1:
+ $this->setCategoryId($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ProductCategoryPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setProductId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ProductCategoryPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ProductCategoryPeer::PRODUCT_ID)) $criteria->add(ProductCategoryPeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(ProductCategoryPeer::CATEGORY_ID)) $criteria->add(ProductCategoryPeer::CATEGORY_ID, $this->category_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ProductCategoryPeer::DATABASE_NAME);
+ $criteria->add(ProductCategoryPeer::PRODUCT_ID, $this->product_id);
+ $criteria->add(ProductCategoryPeer::CATEGORY_ID, $this->category_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getProductId();
+ $pks[1] = $this->getCategoryId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setProductId($keys[0]);
+ $this->setCategoryId($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getProductId()) && (null === $this->getCategoryId());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ProductCategory (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setCategoryId($this->getCategoryId());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ProductCategory Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ProductCategoryPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ProductCategoryPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return ProductCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(Product $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->product_id = null;
+ $this->category_id = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ProductCategoryPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php
new file mode 100644
index 000000000..e3a614cee
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php
@@ -0,0 +1,1383 @@
+ array ('ProductId', 'CategoryId', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('productId', 'categoryId', ),
+ BasePeer::TYPE_COLNAME => array (ProductCategoryPeer::PRODUCT_ID, ProductCategoryPeer::CATEGORY_ID, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('PRODUCT_ID', 'CATEGORY_ID', ),
+ BasePeer::TYPE_FIELDNAME => array ('product_id', 'category_id', ),
+ BasePeer::TYPE_NUM => array (0, 1, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ProductCategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('ProductId' => 0, 'CategoryId' => 1, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('productId' => 0, 'categoryId' => 1, ),
+ BasePeer::TYPE_COLNAME => array (ProductCategoryPeer::PRODUCT_ID => 0, ProductCategoryPeer::CATEGORY_ID => 1, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, ),
+ BasePeer::TYPE_FIELDNAME => array ('product_id' => 0, 'category_id' => 1, ),
+ BasePeer::TYPE_NUM => array (0, 1, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ProductCategoryPeer::getFieldNames($toType);
+ $key = isset(ProductCategoryPeer::$fieldKeys[$fromType][$name]) ? ProductCategoryPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ProductCategoryPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ProductCategoryPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ProductCategoryPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ProductCategoryPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ProductCategoryPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ProductCategoryPeer::PRODUCT_ID);
+ $criteria->addSelectColumn(ProductCategoryPeer::CATEGORY_ID);
+ } else {
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ProductCategory
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ProductCategoryPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ProductCategoryPeer::populateObjects(ProductCategoryPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ProductCategoryPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ProductCategory $obj A ProductCategory object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = serialize(array((string) $obj->getProductId(), (string) $obj->getCategoryId()));
+ } // if key === null
+ ProductCategoryPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ProductCategory object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ProductCategory) {
+ $key = serialize(array((string) $value->getProductId(), (string) $value->getCategoryId()));
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ProductCategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ProductCategoryPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ProductCategory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ProductCategoryPeer::$instances[$key])) {
+ return ProductCategoryPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ProductCategoryPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to product_category
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null && $row[$startcol + 1] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return array((int) $row[$startcol], (int) $row[$startcol + 1]);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ProductCategoryPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ProductCategoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ProductCategoryPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ProductCategory object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ProductCategoryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ProductCategoryPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ProductCategoryPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ProductCategoryPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ProductCategoryPeer::DATABASE_NAME)->getTable(ProductCategoryPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseProductCategoryPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseProductCategoryPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ProductCategoryTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ProductCategoryPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ProductCategory or Criteria object.
+ *
+ * @param mixed $values Criteria or ProductCategory object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ProductCategory object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ProductCategory or Criteria object.
+ *
+ * @param mixed $values Criteria or ProductCategory object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ProductCategoryPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ProductCategoryPeer::PRODUCT_ID);
+ $value = $criteria->remove(ProductCategoryPeer::PRODUCT_ID);
+ if ($value) {
+ $selectCriteria->add(ProductCategoryPeer::PRODUCT_ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(ProductCategoryPeer::CATEGORY_ID);
+ $value = $criteria->remove(ProductCategoryPeer::CATEGORY_ID);
+ if ($value) {
+ $selectCriteria->add(ProductCategoryPeer::CATEGORY_ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ProductCategory object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the product_category table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ProductCategoryPeer::clearInstancePool();
+ ProductCategoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ProductCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ProductCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria = new Criteria(ProductCategoryPeer::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $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);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ProductCategoryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ProductCategory object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ProductCategory $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ProductCategoryPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ProductCategoryPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ProductCategoryPeer::DATABASE_NAME, ProductCategoryPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve object using using composite pkey values.
+ * @param int $product_id
+ * @param int $category_id
+ * @param PropelPDO $con
+ * @return ProductCategory
+ */
+ public static function retrieveByPK($product_id, $category_id, PropelPDO $con = null) {
+ $_instancePoolKey = serialize(array((string) $product_id, (string) $category_id));
+ if (null !== ($obj = ProductCategoryPeer::getInstanceFromPool($_instancePoolKey))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $criteria = new Criteria(ProductCategoryPeer::DATABASE_NAME);
+ $criteria->add(ProductCategoryPeer::PRODUCT_ID, $product_id);
+ $criteria->add(ProductCategoryPeer::CATEGORY_ID, $category_id);
+ $v = ProductCategoryPeer::doSelect($criteria, $con);
+
+ return !empty($v) ? $v[0] : null;
+ }
+} // BaseProductCategoryPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseProductCategoryPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php
new file mode 100644
index 000000000..13124bde2
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php
@@ -0,0 +1,471 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array $key Primary key to use for the query
+ A Primary key composition: [$product_id, $category_id]
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ProductCategory|ProductCategory[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ProductCategoryPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ProductCategory A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `PRODUCT_ID`, `CATEGORY_ID` FROM `product_category` WHERE `PRODUCT_ID` = :p0 AND `CATEGORY_ID` = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ProductCategory();
+ $obj->hydrate($row);
+ ProductCategoryPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ProductCategory|ProductCategory[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ProductCategory[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ProductCategoryPeer::PRODUCT_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ProductCategoryPeer::CATEGORY_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId, $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 ProductCategoryQuery 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(ProductCategoryPeer::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductCategoryPeer::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 ProductCategoryQuery 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');
+ }
+
+ /**
+ * 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
+ *
+ * @param ProductCategory $productCategory Object to remove from the list of results
+ *
+ * @return ProductCategoryQuery The current query, for fluid interface
+ */
+ public function prune($productCategory = null)
+ {
+ if ($productCategory) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ProductCategoryPeer::PRODUCT_ID), $productCategory->getProductId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ProductCategoryPeer::CATEGORY_ID), $productCategory->getCategoryId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseProductDesc.php b/core/lib/Thelia/Model/om/BaseProductDesc.php
new file mode 100644
index 000000000..220311ec5
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductDesc.php
@@ -0,0 +1,1346 @@
+id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->postscriptum;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [updatet_at] column value.
+ *
+ * @return string
+ */
+ public function getUpdatetAt()
+ {
+ return $this->updatet_at;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ProductDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = ProductDescPeer::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = ProductDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ProductDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ProductDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ProductDescPeer::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = ProductDescPeer::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ProductDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Set the value of [updatet_at] column.
+ *
+ * @param string $v new value
+ * @return ProductDesc The current object (for fluent API support)
+ */
+ public function setUpdatetAt($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->updatet_at !== $v) {
+ $this->updatet_at = $v;
+ $this->modifiedColumns[] = ProductDescPeer::UPDATET_AT;
+ }
+
+
+ return $this;
+ } // setUpdatetAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->postscriptum = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->updatet_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = ProductDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ProductDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ProductDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ProductDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ProductDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ProductDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ProductDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ProductDescPeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(ProductDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(ProductDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(ProductDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(ProductDescPeer::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = '`CHAPO`';
+ }
+ if ($this->isColumnModified(ProductDescPeer::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`';
+ }
+ if ($this->isColumnModified(ProductDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ProductDescPeer::UPDATET_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATET_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `product_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CHAPO`':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case '`POSTSCRIPTUM`':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATET_AT`':
+ $stmt->bindValue($identifier, $this->updatet_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ProductDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getProductId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getPostscriptum();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ return $this->getUpdatetAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ProductDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ProductDesc'][$this->getPrimaryKey()] = true;
+ $keys = ProductDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getPostscriptum(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatetAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ProductDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setProductId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setPostscriptum($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $this->setUpdatetAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ProductDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setPostscriptum($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatetAt($arr[$keys[8]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ProductDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ProductDescPeer::ID)) $criteria->add(ProductDescPeer::ID, $this->id);
+ if ($this->isColumnModified(ProductDescPeer::PRODUCT_ID)) $criteria->add(ProductDescPeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(ProductDescPeer::LANG)) $criteria->add(ProductDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(ProductDescPeer::TITLE)) $criteria->add(ProductDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(ProductDescPeer::DESCRIPTION)) $criteria->add(ProductDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ProductDescPeer::CHAPO)) $criteria->add(ProductDescPeer::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ProductDescPeer::POSTSCRIPTUM)) $criteria->add(ProductDescPeer::POSTSCRIPTUM, $this->postscriptum);
+ if ($this->isColumnModified(ProductDescPeer::CREATED_AT)) $criteria->add(ProductDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ProductDescPeer::UPDATET_AT)) $criteria->add(ProductDescPeer::UPDATET_AT, $this->updatet_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ProductDescPeer::DATABASE_NAME);
+ $criteria->add(ProductDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ProductDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatetAt($this->getUpdatetAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ProductDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ProductDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ProductDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return ProductDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(Product $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->created_at = null;
+ $this->updatet_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProduct = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ProductDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseProductDescPeer.php b/core/lib/Thelia/Model/om/BaseProductDescPeer.php
new file mode 100644
index 000000000..dfa73efe9
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductDescPeer.php
@@ -0,0 +1,1042 @@
+ array ('Id', 'ProductId', 'Lang', 'Title', 'Description', 'Chapo', 'Postscriptum', 'CreatedAt', 'UpdatetAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'createdAt', 'updatetAt', ),
+ BasePeer::TYPE_COLNAME => array (ProductDescPeer::ID, ProductDescPeer::PRODUCT_ID, ProductDescPeer::LANG, ProductDescPeer::TITLE, ProductDescPeer::DESCRIPTION, ProductDescPeer::CHAPO, ProductDescPeer::POSTSCRIPTUM, ProductDescPeer::CREATED_AT, ProductDescPeer::UPDATET_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'CREATED_AT', 'UPDATET_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'created_at', 'updatet_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ProductDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Postscriptum' => 6, 'CreatedAt' => 7, 'UpdatetAt' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'createdAt' => 7, 'updatetAt' => 8, ),
+ BasePeer::TYPE_COLNAME => array (ProductDescPeer::ID => 0, ProductDescPeer::PRODUCT_ID => 1, ProductDescPeer::LANG => 2, ProductDescPeer::TITLE => 3, ProductDescPeer::DESCRIPTION => 4, ProductDescPeer::CHAPO => 5, ProductDescPeer::POSTSCRIPTUM => 6, ProductDescPeer::CREATED_AT => 7, ProductDescPeer::UPDATET_AT => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'POSTSCRIPTUM' => 6, 'CREATED_AT' => 7, 'UPDATET_AT' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'created_at' => 7, 'updatet_at' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ProductDescPeer::getFieldNames($toType);
+ $key = isset(ProductDescPeer::$fieldKeys[$fromType][$name]) ? ProductDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ProductDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ProductDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ProductDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ProductDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ProductDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ProductDescPeer::ID);
+ $criteria->addSelectColumn(ProductDescPeer::PRODUCT_ID);
+ $criteria->addSelectColumn(ProductDescPeer::LANG);
+ $criteria->addSelectColumn(ProductDescPeer::TITLE);
+ $criteria->addSelectColumn(ProductDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(ProductDescPeer::CHAPO);
+ $criteria->addSelectColumn(ProductDescPeer::POSTSCRIPTUM);
+ $criteria->addSelectColumn(ProductDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(ProductDescPeer::UPDATET_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATET_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ProductDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ProductDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ProductDescPeer::populateObjects(ProductDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ProductDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ProductDesc $obj A ProductDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ProductDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ProductDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ProductDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ProductDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ProductDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ProductDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ProductDescPeer::$instances[$key])) {
+ return ProductDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ProductDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to product_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ProductDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ProductDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ProductDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ProductDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ProductDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ProductDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ProductDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ProductDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ProductDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ProductDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ProductDescPeer::DATABASE_NAME)->getTable(ProductDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseProductDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseProductDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ProductDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ProductDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ProductDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ProductDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ProductDesc object
+ }
+
+ if ($criteria->containsKey(ProductDescPeer::ID) && $criteria->keyContainsValue(ProductDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ProductDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ProductDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ProductDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ProductDescPeer::ID);
+ $value = $criteria->remove(ProductDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ProductDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ProductDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ProductDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the product_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ProductDescPeer::clearInstancePool();
+ ProductDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ProductDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ProductDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ProductDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ProductDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ProductDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ProductDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ProductDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ProductDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ProductDescPeer::DATABASE_NAME, ProductDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return ProductDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ProductDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ProductDescPeer::DATABASE_NAME);
+ $criteria->add(ProductDescPeer::ID, $pk);
+
+ $v = ProductDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return ProductDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ProductDescPeer::DATABASE_NAME);
+ $criteria->add(ProductDescPeer::ID, $pks, Criteria::IN);
+ $objs = ProductDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseProductDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseProductDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseProductDescQuery.php b/core/lib/Thelia/Model/om/BaseProductDescQuery.php
new file mode 100644
index 000000000..bd0ecad55
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductDescQuery.php
@@ -0,0 +1,632 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ProductDesc|ProductDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ProductDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ProductDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ProductDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PRODUCT_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM`, `CREATED_AT`, `UPDATET_AT` FROM `product_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ProductDesc();
+ $obj->hydrate($row);
+ ProductDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ProductDesc|ProductDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ProductDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ProductDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ProductDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(ProductDescPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(ProductDescPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ProductDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ProductDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updatet_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatetAt('fooValue'); // WHERE updatet_at = 'fooValue'
+ * $query->filterByUpdatetAt('%fooValue%'); // WHERE updatet_at LIKE '%fooValue%'
+ *
+ *
+ * @param string $updatetAt The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatetAt($updatetAt = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($updatetAt)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $updatetAt)) {
+ $updatetAt = str_replace('*', '%', $updatetAt);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductDescPeer::UPDATET_AT, $updatetAt, $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 ProductDescQuery 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(ProductDescPeer::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductDescPeer::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 ProductDescQuery 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
+ *
+ * @param ProductDesc $productDesc Object to remove from the list of results
+ *
+ * @return ProductDescQuery The current query, for fluid interface
+ */
+ public function prune($productDesc = null)
+ {
+ if ($productDesc) {
+ $this->addUsingAlias(ProductDescPeer::ID, $productDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseProductPeer.php b/core/lib/Thelia/Model/om/BaseProductPeer.php
new file mode 100644
index 000000000..52b5aaaf3
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductPeer.php
@@ -0,0 +1,1106 @@
+ array ('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Quantity', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ProductPeer::ID, ProductPeer::TAX_RULE_ID, ProductPeer::REF, ProductPeer::PRICE, ProductPeer::PRICE2, ProductPeer::ECOTAX, ProductPeer::NEWNESS, ProductPeer::PROMO, ProductPeer::QUANTITY, ProductPeer::VISIBLE, ProductPeer::WEIGHT, ProductPeer::POSITION, ProductPeer::CREATED_AT, ProductPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'REF', 'PRICE', 'PRICE2', 'ECOTAX', 'NEWNESS', 'PROMO', 'QUANTITY', 'VISIBLE', 'WEIGHT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ProductPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Price' => 3, 'Price2' => 4, 'Ecotax' => 5, 'Newness' => 6, 'Promo' => 7, 'Quantity' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'quantity' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'createdAt' => 12, 'updatedAt' => 13, ),
+ BasePeer::TYPE_COLNAME => array (ProductPeer::ID => 0, ProductPeer::TAX_RULE_ID => 1, ProductPeer::REF => 2, ProductPeer::PRICE => 3, ProductPeer::PRICE2 => 4, ProductPeer::ECOTAX => 5, ProductPeer::NEWNESS => 6, ProductPeer::PROMO => 7, ProductPeer::QUANTITY => 8, ProductPeer::VISIBLE => 9, ProductPeer::WEIGHT => 10, ProductPeer::POSITION => 11, ProductPeer::CREATED_AT => 12, ProductPeer::UPDATED_AT => 13, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'PRICE' => 3, 'PRICE2' => 4, 'ECOTAX' => 5, 'NEWNESS' => 6, 'PROMO' => 7, 'QUANTITY' => 8, 'VISIBLE' => 9, 'WEIGHT' => 10, 'POSITION' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'quantity' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'created_at' => 12, 'updated_at' => 13, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ProductPeer::getFieldNames($toType);
+ $key = isset(ProductPeer::$fieldKeys[$fromType][$name]) ? ProductPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ProductPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ProductPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ProductPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ProductPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ProductPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ProductPeer::ID);
+ $criteria->addSelectColumn(ProductPeer::TAX_RULE_ID);
+ $criteria->addSelectColumn(ProductPeer::REF);
+ $criteria->addSelectColumn(ProductPeer::PRICE);
+ $criteria->addSelectColumn(ProductPeer::PRICE2);
+ $criteria->addSelectColumn(ProductPeer::ECOTAX);
+ $criteria->addSelectColumn(ProductPeer::NEWNESS);
+ $criteria->addSelectColumn(ProductPeer::PROMO);
+ $criteria->addSelectColumn(ProductPeer::QUANTITY);
+ $criteria->addSelectColumn(ProductPeer::VISIBLE);
+ $criteria->addSelectColumn(ProductPeer::WEIGHT);
+ $criteria->addSelectColumn(ProductPeer::POSITION);
+ $criteria->addSelectColumn(ProductPeer::CREATED_AT);
+ $criteria->addSelectColumn(ProductPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.PRICE');
+ $criteria->addSelectColumn($alias . '.PRICE2');
+ $criteria->addSelectColumn($alias . '.ECOTAX');
+ $criteria->addSelectColumn($alias . '.NEWNESS');
+ $criteria->addSelectColumn($alias . '.PROMO');
+ $criteria->addSelectColumn($alias . '.QUANTITY');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.WEIGHT');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ProductPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Product
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ProductPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ProductPeer::populateObjects(ProductPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ProductPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Product $obj A Product object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ProductPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Product object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Product) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Product object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ProductPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Product Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ProductPeer::$instances[$key])) {
+ return ProductPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ProductPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to product
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in AccessoryPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AccessoryPeer::clearInstancePool();
+ // Invalidate objects in AccessoryPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AccessoryPeer::clearInstancePool();
+ // Invalidate objects in ContentAssocPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ContentAssocPeer::clearInstancePool();
+ // Invalidate objects in DocumentPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ DocumentPeer::clearInstancePool();
+ // Invalidate objects in FeatureProdPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ FeatureProdPeer::clearInstancePool();
+ // Invalidate objects in ImagePeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ImagePeer::clearInstancePool();
+ // Invalidate objects in ProductCategoryPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ProductCategoryPeer::clearInstancePool();
+ // Invalidate objects in ProductDescPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ProductDescPeer::clearInstancePool();
+ // Invalidate objects in RewritingPeer instance pool,
+ // 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ProductPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ProductPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ProductPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Product object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ProductPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ProductPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ProductPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ProductPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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(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::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 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
+ * @return array Array of Product 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(ProductPeer::DATABASE_NAME);
+ }
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol = ProductPeer::NUM_HYDRATE_COLUMNS;
+ TaxRulePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::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 = 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 (Product) to $obj2 (TaxRule)
+ $obj2->addProduct($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(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::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 Product 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 Product 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(ProductPeer::DATABASE_NAME);
+ }
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ TaxRulePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + TaxRulePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::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 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 (Product) to the collection in $obj2 (TaxRule)
+ $obj2->addProduct($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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ProductPeer::DATABASE_NAME)->getTable(ProductPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseProductPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseProductPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ProductTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ProductPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Product or Criteria object.
+ *
+ * @param mixed $values Criteria or Product object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Product object
+ }
+
+ if ($criteria->containsKey(ProductPeer::ID) && $criteria->keyContainsValue(ProductPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Product or Criteria object.
+ *
+ * @param mixed $values Criteria or Product object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ProductPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ProductPeer::ID);
+ $value = $criteria->remove(ProductPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ProductPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ProductPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Product object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ProductPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the product table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ProductPeer::clearInstancePool();
+ ProductPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Product or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Product object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ProductPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ProductPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Product object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Product $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ProductPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ProductPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ProductPeer::DATABASE_NAME, ProductPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Product
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ProductPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ProductPeer::DATABASE_NAME);
+ $criteria->add(ProductPeer::ID, $pk);
+
+ $v = ProductPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Product[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ProductPeer::DATABASE_NAME);
+ $criteria->add(ProductPeer::ID, $pks, Criteria::IN);
+ $objs = ProductPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseProductPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseProductPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseProductQuery.php b/core/lib/Thelia/Model/om/BaseProductQuery.php
new file mode 100644
index 000000000..0bd645f34
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductQuery.php
@@ -0,0 +1,1708 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Product|Product[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ProductPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Product A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `PRICE`, `PRICE2`, `ECOTAX`, `NEWNESS`, `PROMO`, `QUANTITY`, `VISIBLE`, `WEIGHT`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `product` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Product();
+ $obj->hydrate($row);
+ ProductPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Product|Product[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Product[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ProductPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ProductPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ProductPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234
+ * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34)
+ * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
+ *
+ *
+ * @see filterByTaxRule()
+ *
+ * @param mixed $taxRuleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleId($taxRuleId = null, $comparison = null)
+ {
+ if (is_array($taxRuleId)) {
+ $useMinMax = false;
+ if (isset($taxRuleId['min'])) {
+ $this->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxRuleId['max'])) {
+ $this->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRuleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the price column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice(1234); // WHERE price = 1234
+ * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
+ * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
+ *
+ *
+ * @param mixed $price The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByPrice($price = null, $comparison = null)
+ {
+ if (is_array($price)) {
+ $useMinMax = false;
+ if (isset($price['min'])) {
+ $this->addUsingAlias(ProductPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price['max'])) {
+ $this->addUsingAlias(ProductPeer::PRICE, $price['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::PRICE, $price, $comparison);
+ }
+
+ /**
+ * Filter the query on the price2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice2(1234); // WHERE price2 = 1234
+ * $query->filterByPrice2(array(12, 34)); // WHERE price2 IN (12, 34)
+ * $query->filterByPrice2(array('min' => 12)); // WHERE price2 > 12
+ *
+ *
+ * @param mixed $price2 The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByPrice2($price2 = null, $comparison = null)
+ {
+ if (is_array($price2)) {
+ $useMinMax = false;
+ if (isset($price2['min'])) {
+ $this->addUsingAlias(ProductPeer::PRICE2, $price2['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price2['max'])) {
+ $this->addUsingAlias(ProductPeer::PRICE2, $price2['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::PRICE2, $price2, $comparison);
+ }
+
+ /**
+ * Filter the query on the ecotax column
+ *
+ * Example usage:
+ *
+ * $query->filterByEcotax(1234); // WHERE ecotax = 1234
+ * $query->filterByEcotax(array(12, 34)); // WHERE ecotax IN (12, 34)
+ * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax > 12
+ *
+ *
+ * @param mixed $ecotax The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByEcotax($ecotax = null, $comparison = null)
+ {
+ if (is_array($ecotax)) {
+ $useMinMax = false;
+ if (isset($ecotax['min'])) {
+ $this->addUsingAlias(ProductPeer::ECOTAX, $ecotax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($ecotax['max'])) {
+ $this->addUsingAlias(ProductPeer::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::ECOTAX, $ecotax, $comparison);
+ }
+
+ /**
+ * Filter the query on the newness column
+ *
+ * Example usage:
+ *
+ * $query->filterByNewness(1234); // WHERE newness = 1234
+ * $query->filterByNewness(array(12, 34)); // WHERE newness IN (12, 34)
+ * $query->filterByNewness(array('min' => 12)); // WHERE newness > 12
+ *
+ *
+ * @param mixed $newness The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByNewness($newness = null, $comparison = null)
+ {
+ if (is_array($newness)) {
+ $useMinMax = false;
+ if (isset($newness['min'])) {
+ $this->addUsingAlias(ProductPeer::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($newness['max'])) {
+ $this->addUsingAlias(ProductPeer::NEWNESS, $newness['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::NEWNESS, $newness, $comparison);
+ }
+
+ /**
+ * Filter the query on the promo column
+ *
+ * Example usage:
+ *
+ * $query->filterByPromo(1234); // WHERE promo = 1234
+ * $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34)
+ * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12
+ *
+ *
+ * @param mixed $promo The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByPromo($promo = null, $comparison = null)
+ {
+ if (is_array($promo)) {
+ $useMinMax = false;
+ if (isset($promo['min'])) {
+ $this->addUsingAlias(ProductPeer::PROMO, $promo['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($promo['max'])) {
+ $this->addUsingAlias(ProductPeer::PROMO, $promo['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::PROMO, $promo, $comparison);
+ }
+
+ /**
+ * Filter the query on the quantity column
+ *
+ * Example usage:
+ *
+ * $query->filterByQuantity(1234); // WHERE quantity = 1234
+ * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
+ * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
+ *
+ *
+ * @param mixed $quantity The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByQuantity($quantity = null, $comparison = null)
+ {
+ if (is_array($quantity)) {
+ $useMinMax = false;
+ if (isset($quantity['min'])) {
+ $this->addUsingAlias(ProductPeer::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($quantity['max'])) {
+ $this->addUsingAlias(ProductPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::QUANTITY, $quantity, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(ProductPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(ProductPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the weight column
+ *
+ * Example usage:
+ *
+ * $query->filterByWeight(1234); // WHERE weight = 1234
+ * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34)
+ * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12
+ *
+ *
+ * @param mixed $weight The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByWeight($weight = null, $comparison = null)
+ {
+ if (is_array($weight)) {
+ $useMinMax = false;
+ if (isset($weight['min'])) {
+ $this->addUsingAlias(ProductPeer::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($weight['max'])) {
+ $this->addUsingAlias(ProductPeer::WEIGHT, $weight['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::WEIGHT, $weight, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ProductPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ProductPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ProductPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ProductPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related TaxRule object
+ *
+ * @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 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) {
+ return $this
+ ->useAccessoryRelatedByProductIdQuery()
+ ->filterByPrimaryKeys($accessory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAccessoryRelatedByProductId() only accepts arguments of type Accessory or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 joinAccessoryRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AccessoryRelatedByProductId');
+
+ // 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, 'AccessoryRelatedByProductId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AccessoryRelatedByProductId relation Accessory 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\AccessoryQuery A secondary query class using the current class as primary query
+ */
+ public function useAccessoryRelatedByProductIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->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 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 filterByAccessoryRelatedByAccessory($accessory, $comparison = null)
+ {
+ if ($accessory instanceof Accessory) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $accessory->getAccessory(), $comparison);
+ } elseif ($accessory instanceof PropelObjectCollection) {
+ return $this
+ ->useAccessoryRelatedByAccessoryQuery()
+ ->filterByPrimaryKeys($accessory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAccessoryRelatedByAccessory() only accepts arguments of type Accessory or PropelCollection');
+ }
+ }
+
+ /**
+ * 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 joinAccessoryRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AccessoryRelatedByAccessory');
+
+ // 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, 'AccessoryRelatedByAccessory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AccessoryRelatedByAccessory relation Accessory 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\AccessoryQuery A secondary query class using the current class as primary query
+ */
+ public function useAccessoryRelatedByAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->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 to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContentAssoc($contentAssoc, $comparison = null)
+ {
+ if ($contentAssoc instanceof ContentAssoc) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $contentAssoc->getProductId(), $comparison);
+ } elseif ($contentAssoc instanceof PropelObjectCollection) {
+ return $this
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentAssoc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentAssoc');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentAssoc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentAssoc relation ContentAssoc object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
+ */
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContentAssoc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery');
+ }
+
+ /**
+ * Filter the query by a related Document object
+ *
+ * @param Document|PropelObjectCollection $document the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof Document) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $document->getProductId(), $comparison);
+ } elseif ($document instanceof PropelObjectCollection) {
+ return $this
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Filter the query by a related FeatureProd object
+ *
+ * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFeatureProd($featureProd, $comparison = null)
+ {
+ if ($featureProd instanceof FeatureProd) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $featureProd->getProductId(), $comparison);
+ } elseif ($featureProd instanceof PropelObjectCollection) {
+ return $this
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureProd relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureProd');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureProd');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureProd relation FeatureProd object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureProd($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery');
+ }
+
+ /**
+ * Filter the query by a related Image object
+ *
+ * @param Image|PropelObjectCollection $image the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof Image) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $image->getProductId(), $comparison);
+ } elseif ($image instanceof PropelObjectCollection) {
+ return $this
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Filter the query by a related ProductCategory object
+ *
+ * @param ProductCategory|PropelObjectCollection $productCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByProductCategory($productCategory, $comparison = null)
+ {
+ if ($productCategory instanceof ProductCategory) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $productCategory->getProductId(), $comparison);
+ } elseif ($productCategory instanceof PropelObjectCollection) {
+ return $this
+ ->useProductCategoryQuery()
+ ->filterByPrimaryKeys($productCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductCategory relation ProductCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related ProductDesc object
+ *
+ * @param ProductDesc|PropelObjectCollection $productDesc the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByProductDesc($productDesc, $comparison = null)
+ {
+ if ($productDesc instanceof ProductDesc) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $productDesc->getProductId(), $comparison);
+ } elseif ($productDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useProductDescQuery()
+ ->filterByPrimaryKeys($productDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProductDesc() only accepts arguments of type ProductDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function joinProductDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductDesc');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductDesc relation ProductDesc object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductDescQuery A secondary query class using the current class as primary query
+ */
+ public function useProductDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductDesc', '\Thelia\Model\ProductDescQuery');
+ }
+
+ /**
+ * Filter the query by a related Rewriting object
+ *
+ * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByRewriting($rewriting, $comparison = null)
+ {
+ if ($rewriting instanceof Rewriting) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $rewriting->getProductId(), $comparison);
+ } elseif ($rewriting instanceof PropelObjectCollection) {
+ return $this
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Rewriting 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 joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Rewriting');
+
+ // 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, 'Rewriting');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Rewriting relation Rewriting 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\RewritingQuery A secondary query class using the current class as primary query
+ */
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinRewriting($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
+ }
+
+ /**
+ * Filter the query by a related Stock object
+ *
+ * @param Stock|PropelObjectCollection $stock the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByStock($stock, $comparison = null)
+ {
+ if ($stock instanceof Stock) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $stock->getProductId(), $comparison);
+ } elseif ($stock instanceof PropelObjectCollection) {
+ return $this
+ ->useStockQuery()
+ ->filterByPrimaryKeys($stock->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Stock relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Stock');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Stock');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Stock relation Stock object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query
+ */
+ public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinStock($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Product $product Object to remove from the list of results
+ *
+ * @return ProductQuery The current query, for fluid interface
+ */
+ public function prune($product = null)
+ {
+ if ($product) {
+ $this->addUsingAlias(ProductPeer::ID, $product->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseResource.php b/core/lib/Thelia/Model/om/BaseResource.php
new file mode 100644
index 000000000..f6c844fb8
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseResource.php
@@ -0,0 +1,1584 @@
+id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Resource The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ResourcePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return Resource The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = ResourcePeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Resource The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ResourcePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Resource The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ResourcePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = ResourcePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Resource object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ResourcePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collGroupResources = null;
+
+ $this->collResourceDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ResourceQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ResourcePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ResourcePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ResourcePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ResourcePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ResourcePeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(ResourcePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ResourcePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `resource` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Resource'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Resource'][$this->getPrimaryKey()] = true;
+ $keys = ResourcePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collGroupResources) {
+ $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collResourceDescs) {
+ $result['ResourceDescs'] = $this->collResourceDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ResourcePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ResourcePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ResourcePeer::ID)) $criteria->add(ResourcePeer::ID, $this->id);
+ if ($this->isColumnModified(ResourcePeer::CODE)) $criteria->add(ResourcePeer::CODE, $this->code);
+ if ($this->isColumnModified(ResourcePeer::CREATED_AT)) $criteria->add(ResourcePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ResourcePeer::UPDATED_AT)) $criteria->add(ResourcePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ResourcePeer::DATABASE_NAME);
+ $criteria->add(ResourcePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Resource (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getGroupResources() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupResource($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getResourceDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addResourceDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Resource Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ResourcePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ResourcePeer();
+ }
+
+ 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.
+ *
+ * @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 getGroupResources($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collGroupResourcesPartial && !$this->isNew();
+ if (null === $this->collGroupResources || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupResources) {
+ // return empty collection
+ $this->initGroupResources();
+ } else {
+ $collGroupResources = GroupResourceQuery::create(null, $criteria)
+ ->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 {
+ return count($this->collGroupResources);
+ }
+ }
+
+ /**
+ * Method called to associate a GroupResource object to this object
+ * through the GroupResource foreign key attribute.
+ *
+ * @param GroupResource $l GroupResource
+ * @return 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;
+ }
+
+ /**
+ * @param GroupResource $groupResource The groupResource object to add.
+ */
+ protected function doAddGroupResource($groupResource)
+ {
+ $this->collGroupResources[]= $groupResource;
+ $groupResource->setResource($this);
+ }
+
+ /**
+ * @param GroupResource $groupResource The groupResource object to remove.
+ */
+ public function removeGroupResource($groupResource)
+ {
+ if ($this->getGroupResources()->contains($groupResource)) {
+ $this->collGroupResources->remove($this->collGroupResources->search($groupResource));
+ if (null === $this->groupResourcesScheduledForDeletion) {
+ $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources;
+ $this->groupResourcesScheduledForDeletion->clear();
+ }
+ $this->groupResourcesScheduledForDeletion[]= $groupResource;
+ $groupResource->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.
+ *
+ * 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 getResourceDescs($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collResourceDescsPartial && !$this->isNew();
+ if (null === $this->collResourceDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collResourceDescs) {
+ // return empty collection
+ $this->initResourceDescs();
+ } else {
+ $collResourceDescs = ResourceDescQuery::create(null, $criteria)
+ ->filterByResource($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collResourceDescsPartial && count($collResourceDescs)) {
+ $this->initResourceDescs(false);
+
+ foreach($collResourceDescs as $obj) {
+ if (false == $this->collResourceDescs->contains($obj)) {
+ $this->collResourceDescs->append($obj);
+ }
+ }
+
+ $this->collResourceDescsPartial = true;
+ }
+
+ return $collResourceDescs;
+ }
+
+ if($partial && $this->collResourceDescs) {
+ foreach($this->collResourceDescs as $obj) {
+ if($obj->isNew()) {
+ $collResourceDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collResourceDescs = $collResourceDescs;
+ $this->collResourceDescsPartial = false;
+ }
+ }
+
+ return $this->collResourceDescs;
+ }
+
+ /**
+ * Sets a collection of ResourceDesc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $resourceDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setResourceDescs(PropelCollection $resourceDescs, PropelPDO $con = null)
+ {
+ $this->resourceDescsScheduledForDeletion = $this->getResourceDescs(new Criteria(), $con)->diff($resourceDescs);
+
+ foreach ($this->resourceDescsScheduledForDeletion as $resourceDescRemoved) {
+ $resourceDescRemoved->setResource(null);
+ }
+
+ $this->collResourceDescs = null;
+ foreach ($resourceDescs as $resourceDesc) {
+ $this->addResourceDesc($resourceDesc);
+ }
+
+ $this->collResourceDescs = $resourceDescs;
+ $this->collResourceDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related ResourceDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ResourceDesc objects.
+ * @throws PropelException
+ */
+ public function countResourceDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collResourceDescsPartial && !$this->isNew();
+ if (null === $this->collResourceDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collResourceDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getResourceDescs());
+ }
+ $query = ResourceDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByResource($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collResourceDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a ResourceDesc object to this object
+ * through the ResourceDesc foreign key attribute.
+ *
+ * @param ResourceDesc $l ResourceDesc
+ * @return Resource The current object (for fluent API support)
+ */
+ public function addResourceDesc(ResourceDesc $l)
+ {
+ if ($this->collResourceDescs === null) {
+ $this->initResourceDescs();
+ $this->collResourceDescsPartial = true;
+ }
+ if (!$this->collResourceDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddResourceDesc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ResourceDesc $resourceDesc The resourceDesc object to add.
+ */
+ protected function doAddResourceDesc($resourceDesc)
+ {
+ $this->collResourceDescs[]= $resourceDesc;
+ $resourceDesc->setResource($this);
+ }
+
+ /**
+ * @param ResourceDesc $resourceDesc The resourceDesc object to remove.
+ */
+ public function removeResourceDesc($resourceDesc)
+ {
+ if ($this->getResourceDescs()->contains($resourceDesc)) {
+ $this->collResourceDescs->remove($this->collResourceDescs->search($resourceDesc));
+ if (null === $this->resourceDescsScheduledForDeletion) {
+ $this->resourceDescsScheduledForDeletion = clone $this->collResourceDescs;
+ $this->resourceDescsScheduledForDeletion->clear();
+ }
+ $this->resourceDescsScheduledForDeletion[]= $resourceDesc;
+ $resourceDesc->setResource(null);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ if ($this->collGroupResources instanceof PropelCollection) {
+ $this->collGroupResources->clearIterator();
+ }
+ $this->collGroupResources = null;
+ if ($this->collResourceDescs instanceof PropelCollection) {
+ $this->collResourceDescs->clearIterator();
+ }
+ $this->collResourceDescs = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ResourcePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseResourceDesc.php b/core/lib/Thelia/Model/om/BaseResourceDesc.php
new file mode 100644
index 000000000..cb9f40450
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseResourceDesc.php
@@ -0,0 +1,1210 @@
+id;
+ }
+
+ /**
+ * Get the [resource_id] column value.
+ *
+ * @return int
+ */
+ public function getResourceId()
+ {
+ return $this->resource_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ResourceDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ResourceDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [resource_id] column.
+ *
+ * @param int $v new value
+ * @return ResourceDesc The current object (for fluent API support)
+ */
+ public function setResourceId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->resource_id !== $v) {
+ $this->resource_id = $v;
+ $this->modifiedColumns[] = ResourceDescPeer::RESOURCE_ID;
+ }
+
+ if ($this->aResource !== null && $this->aResource->getId() !== $v) {
+ $this->aResource = null;
+ }
+
+
+ return $this;
+ } // setResourceId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return ResourceDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = ResourceDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return ResourceDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ResourceDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ResourceDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = ResourceDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ResourceDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = ResourceDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->resource_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = ResourceDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ResourceDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aResource !== null && $this->resource_id !== $this->aResource->getId()) {
+ $this->aResource = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ResourceDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aResource = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ResourceDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ResourceDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ResourceDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ResourceDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ResourceDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ResourceDescPeer::RESOURCE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`RESOURCE_ID`';
+ }
+ if ($this->isColumnModified(ResourceDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(ResourceDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(ResourceDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ResourceDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `resource_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`RESOURCE_ID`':
+ $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ResourceDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getResourceId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ResourceDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ResourceDesc'][$this->getPrimaryKey()] = true;
+ $keys = ResourceDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getResourceId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aResource) {
+ $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ResourceDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setResourceId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ResourceDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setResourceId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ResourceDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ResourceDescPeer::ID)) $criteria->add(ResourceDescPeer::ID, $this->id);
+ if ($this->isColumnModified(ResourceDescPeer::RESOURCE_ID)) $criteria->add(ResourceDescPeer::RESOURCE_ID, $this->resource_id);
+ if ($this->isColumnModified(ResourceDescPeer::LANG)) $criteria->add(ResourceDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(ResourceDescPeer::TITLE)) $criteria->add(ResourceDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(ResourceDescPeer::CREATED_AT)) $criteria->add(ResourceDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ResourceDescPeer::UPDATED_AT)) $criteria->add(ResourceDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ResourceDescPeer::DATABASE_NAME);
+ $criteria->add(ResourceDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ResourceDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setResourceId($this->getResourceId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ResourceDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ResourceDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ResourceDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Resource object.
+ *
+ * @param Resource $v
+ * @return ResourceDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setResource(Resource $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->resource_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aResource = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ResourceDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseResourceDescPeer.php b/core/lib/Thelia/Model/om/BaseResourceDescPeer.php
new file mode 100644
index 000000000..1c2095508
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseResourceDescPeer.php
@@ -0,0 +1,1027 @@
+ array ('Id', 'ResourceId', 'Lang', 'Title', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'resourceId', 'lang', 'title', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ResourceDescPeer::ID, ResourceDescPeer::RESOURCE_ID, ResourceDescPeer::LANG, ResourceDescPeer::TITLE, ResourceDescPeer::CREATED_AT, ResourceDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'RESOURCE_ID', 'LANG', 'TITLE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'resource_id', 'lang', 'title', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ResourceDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ResourceId' => 1, 'Lang' => 2, 'Title' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'resourceId' => 1, 'lang' => 2, 'title' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ BasePeer::TYPE_COLNAME => array (ResourceDescPeer::ID => 0, ResourceDescPeer::RESOURCE_ID => 1, ResourceDescPeer::LANG => 2, ResourceDescPeer::TITLE => 3, ResourceDescPeer::CREATED_AT => 4, ResourceDescPeer::UPDATED_AT => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'RESOURCE_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'resource_id' => 1, 'lang' => 2, 'title' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ResourceDescPeer::getFieldNames($toType);
+ $key = isset(ResourceDescPeer::$fieldKeys[$fromType][$name]) ? ResourceDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ResourceDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ResourceDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ResourceDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ResourceDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ResourceDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ResourceDescPeer::ID);
+ $criteria->addSelectColumn(ResourceDescPeer::RESOURCE_ID);
+ $criteria->addSelectColumn(ResourceDescPeer::LANG);
+ $criteria->addSelectColumn(ResourceDescPeer::TITLE);
+ $criteria->addSelectColumn(ResourceDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(ResourceDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.RESOURCE_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ResourceDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ResourceDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ResourceDescPeer::populateObjects(ResourceDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ResourceDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ResourceDesc $obj A ResourceDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ResourceDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ResourceDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ResourceDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ResourceDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ResourceDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ResourceDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ResourceDescPeer::$instances[$key])) {
+ return ResourceDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ResourceDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to resource_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ResourceDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ResourceDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ResourceDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ResourceDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ResourceDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ResourceDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ResourceDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ResourceDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ResourceDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ResourceDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ResourceDescPeer::DATABASE_NAME)->getTable(ResourceDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseResourceDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseResourceDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ResourceDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ResourceDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ResourceDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ResourceDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ResourceDesc object
+ }
+
+ if ($criteria->containsKey(ResourceDescPeer::ID) && $criteria->keyContainsValue(ResourceDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ResourceDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ResourceDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or ResourceDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ResourceDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ResourceDescPeer::ID);
+ $value = $criteria->remove(ResourceDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ResourceDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ResourceDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ResourceDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the resource_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ ResourceDescPeer::clearInstancePool();
+ ResourceDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ResourceDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ResourceDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(ResourceDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ResourceDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ResourceDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ResourceDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ResourceDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ResourceDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ResourceDescPeer::DATABASE_NAME, ResourceDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return ResourceDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ResourceDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ResourceDescPeer::DATABASE_NAME);
+ $criteria->add(ResourceDescPeer::ID, $pk);
+
+ $v = ResourceDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return ResourceDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ResourceDescPeer::DATABASE_NAME);
+ $criteria->add(ResourceDescPeer::ID, $pks, Criteria::IN);
+ $objs = ResourceDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseResourceDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseResourceDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseResourceDescQuery.php b/core/lib/Thelia/Model/om/BaseResourceDescQuery.php
new file mode 100644
index 000000000..96116f0b5
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseResourceDescQuery.php
@@ -0,0 +1,547 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ResourceDesc|ResourceDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ResourceDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ResourceDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ResourceDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `RESOURCE_ID`, `LANG`, `TITLE`, `CREATED_AT`, `UPDATED_AT` FROM `resource_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ResourceDesc();
+ $obj->hydrate($row);
+ ResourceDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ResourceDesc|ResourceDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ResourceDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ResourceDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ResourceDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ResourceDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the resource_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByResourceId(1234); // WHERE resource_id = 1234
+ * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34)
+ * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12
+ *
+ *
+ * @see filterByResource()
+ *
+ * @param mixed $resourceId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function filterByResourceId($resourceId = null, $comparison = null)
+ {
+ if (is_array($resourceId)) {
+ $useMinMax = false;
+ if (isset($resourceId['min'])) {
+ $this->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($resourceId['max'])) {
+ $this->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resourceId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ResourceDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ResourceDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ResourceDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ResourceDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Resource object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByResource($resource, $comparison = null)
+ {
+ if ($resource instanceof Resource) {
+ return $this
+ ->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resource->getId(), $comparison);
+ } elseif ($resource instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Resource relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Resource');
+
+ // 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, 'Resource');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Resource relation Resource 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\ResourceQuery A secondary query class using the current class as primary query
+ */
+ public function useResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinResource($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ResourceDesc $resourceDesc Object to remove from the list of results
+ *
+ * @return ResourceDescQuery The current query, for fluid interface
+ */
+ public function prune($resourceDesc = null)
+ {
+ if ($resourceDesc) {
+ $this->addUsingAlias(ResourceDescPeer::ID, $resourceDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseResourcePeer.php b/core/lib/Thelia/Model/om/BaseResourcePeer.php
new file mode 100644
index 000000000..8e8b5754c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseResourcePeer.php
@@ -0,0 +1,786 @@
+ array ('Id', 'Code', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (ResourcePeer::ID, ResourcePeer::CODE, ResourcePeer::CREATED_AT, ResourcePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ResourcePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ BasePeer::TYPE_COLNAME => array (ResourcePeer::ID => 0, ResourcePeer::CODE => 1, ResourcePeer::CREATED_AT => 2, ResourcePeer::UPDATED_AT => 3, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ResourcePeer::getFieldNames($toType);
+ $key = isset(ResourcePeer::$fieldKeys[$fromType][$name]) ? ResourcePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ResourcePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ResourcePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ResourcePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ResourcePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ResourcePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ResourcePeer::ID);
+ $criteria->addSelectColumn(ResourcePeer::CODE);
+ $criteria->addSelectColumn(ResourcePeer::CREATED_AT);
+ $criteria->addSelectColumn(ResourcePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(ResourcePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Resource
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ResourcePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ResourcePeer::populateObjects(ResourcePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ResourcePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourcePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Resource $obj A Resource object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ ResourcePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Resource object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Resource) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Resource object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ResourcePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Resource Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ResourcePeer::$instances[$key])) {
+ return ResourcePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ResourcePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to resource
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ResourcePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ResourcePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ResourcePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ResourcePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Resource object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ResourcePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ResourcePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ResourcePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ResourcePeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ResourcePeer::DATABASE_NAME)->getTable(ResourcePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseResourcePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseResourcePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ResourceTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ResourcePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Resource or Criteria object.
+ *
+ * @param mixed $values Criteria or Resource object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Resource object
+ }
+
+ if ($criteria->containsKey(ResourcePeer::ID) && $criteria->keyContainsValue(ResourcePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ResourcePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourcePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Resource or Criteria object.
+ *
+ * @param mixed $values Criteria or Resource object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ResourcePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ResourcePeer::ID);
+ $value = $criteria->remove(ResourcePeer::ID);
+ if ($value) {
+ $selectCriteria->add(ResourcePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ResourcePeer::TABLE_NAME);
+ }
+
+ } else { // $values is Resource object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ResourcePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the resource table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(ResourcePeer::TABLE_NAME, $con, ResourcePeer::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
+ // instances get re-added by the select statement contained therein).
+ ResourcePeer::clearInstancePool();
+ ResourcePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Resource or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Resource object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ ResourcePeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Resource) { // it's a model object
+ // invalidate the cache for this single object
+ ResourcePeer::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(ResourcePeer::DATABASE_NAME);
+ $criteria->add(ResourcePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ResourcePeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourcePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ResourcePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Resource object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Resource $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ResourcePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ResourcePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ResourcePeer::DATABASE_NAME, ResourcePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Resource
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ResourcePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ResourcePeer::DATABASE_NAME);
+ $criteria->add(ResourcePeer::ID, $pk);
+
+ $v = ResourcePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Resource[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ResourcePeer::DATABASE_NAME);
+ $criteria->add(ResourcePeer::ID, $pks, Criteria::IN);
+ $objs = ResourcePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseResourcePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseResourcePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseResourceQuery.php b/core/lib/Thelia/Model/om/BaseResourceQuery.php
new file mode 100644
index 000000000..9ae6f0863
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseResourceQuery.php
@@ -0,0 +1,544 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Resource|Resource[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ResourcePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Resource A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CODE`, `CREATED_AT`, `UPDATED_AT` FROM `resource` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Resource();
+ $obj->hydrate($row);
+ ResourcePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Resource|Resource[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Resource[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ResourcePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ResourcePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ResourcePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourcePeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related GroupResource object
+ *
+ * @param GroupResource|PropelObjectCollection $groupResource the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByGroupResource($groupResource, $comparison = null)
+ {
+ if ($groupResource instanceof GroupResource) {
+ return $this
+ ->addUsingAlias(ResourcePeer::ID, $groupResource->getResourceId(), $comparison);
+ } elseif ($groupResource instanceof PropelObjectCollection) {
+ return $this
+ ->useGroupResourceQuery()
+ ->filterByPrimaryKeys($groupResource->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupResource relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupResource');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupResource');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupResource relation GroupResource object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroupResource($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery');
+ }
+
+ /**
+ * Filter the query by a related ResourceDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByResourceDesc($resourceDesc, $comparison = null)
+ {
+ if ($resourceDesc instanceof ResourceDesc) {
+ return $this
+ ->addUsingAlias(ResourcePeer::ID, $resourceDesc->getResourceId(), $comparison);
+ } elseif ($resourceDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useResourceDescQuery()
+ ->filterByPrimaryKeys($resourceDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByResourceDesc() only accepts arguments of type ResourceDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ResourceDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function joinResourceDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ResourceDesc');
+
+ // 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, 'ResourceDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ResourceDesc relation ResourceDesc 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\ResourceDescQuery A secondary query class using the current class as primary query
+ */
+ public function useResourceDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinResourceDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ResourceDesc', '\Thelia\Model\ResourceDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Resource $resource Object to remove from the list of results
+ *
+ * @return ResourceQuery The current query, for fluid interface
+ */
+ public function prune($resource = null)
+ {
+ if ($resource) {
+ $this->addUsingAlias(ResourcePeer::ID, $resource->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseRewriting.php b/core/lib/Thelia/Model/om/BaseRewriting.php
new file mode 100644
index 000000000..87352cd3c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseRewriting.php
@@ -0,0 +1,1558 @@
+id;
+ }
+
+ /**
+ * Get the [url] column value.
+ *
+ * @return string
+ */
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+ return $this->folder_id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Rewriting The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = RewritingPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [url] column.
+ *
+ * @param string $v new value
+ * @return Rewriting The current object (for fluent API support)
+ */
+ public function setUrl($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->url !== $v) {
+ $this->url = $v;
+ $this->modifiedColumns[] = RewritingPeer::URL;
+ }
+
+
+ return $this;
+ } // setUrl()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return Rewriting The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = RewritingPeer::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return Rewriting The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = RewritingPeer::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return Rewriting The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = RewritingPeer::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return Rewriting The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = RewritingPeer::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Rewriting The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = RewritingPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Rewriting The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = RewritingPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->url = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->product_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->category_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->folder_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->content_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
+ $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = RewritingPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Rewriting object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = RewritingPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aFolder = null;
+ $this->aContent = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = RewritingQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ RewritingPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(RewritingPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(RewritingPeer::URL)) {
+ $modifiedColumns[':p' . $index++] = '`URL`';
+ }
+ if ($this->isColumnModified(RewritingPeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(RewritingPeer::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`';
+ }
+ if ($this->isColumnModified(RewritingPeer::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = '`FOLDER_ID`';
+ }
+ if ($this->isColumnModified(RewritingPeer::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`CONTENT_ID`';
+ }
+ if ($this->isColumnModified(RewritingPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(RewritingPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `rewriting` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`URL`':
+ $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
+ break;
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`CATEGORY_ID`':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case '`FOLDER_ID`':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ case '`CONTENT_ID`':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = RewritingPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getUrl();
+ break;
+ case 2:
+ return $this->getProductId();
+ break;
+ case 3:
+ return $this->getCategoryId();
+ break;
+ case 4:
+ return $this->getFolderId();
+ break;
+ case 5:
+ return $this->getContentId();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Rewriting'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Rewriting'][$this->getPrimaryKey()] = true;
+ $keys = RewritingPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getUrl(),
+ $keys[2] => $this->getProductId(),
+ $keys[3] => $this->getCategoryId(),
+ $keys[4] => $this->getFolderId(),
+ $keys[5] => $this->getContentId(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = RewritingPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setUrl($value);
+ break;
+ case 2:
+ $this->setProductId($value);
+ break;
+ case 3:
+ $this->setCategoryId($value);
+ break;
+ case 4:
+ $this->setFolderId($value);
+ break;
+ case 5:
+ $this->setContentId($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = RewritingPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setUrl($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCategoryId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setFolderId($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setContentId($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(RewritingPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(RewritingPeer::ID)) $criteria->add(RewritingPeer::ID, $this->id);
+ if ($this->isColumnModified(RewritingPeer::URL)) $criteria->add(RewritingPeer::URL, $this->url);
+ if ($this->isColumnModified(RewritingPeer::PRODUCT_ID)) $criteria->add(RewritingPeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(RewritingPeer::CATEGORY_ID)) $criteria->add(RewritingPeer::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(RewritingPeer::FOLDER_ID)) $criteria->add(RewritingPeer::FOLDER_ID, $this->folder_id);
+ if ($this->isColumnModified(RewritingPeer::CONTENT_ID)) $criteria->add(RewritingPeer::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(RewritingPeer::CREATED_AT)) $criteria->add(RewritingPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(RewritingPeer::UPDATED_AT)) $criteria->add(RewritingPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(RewritingPeer::DATABASE_NAME);
+ $criteria->add(RewritingPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Rewriting (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setUrl($this->getUrl());
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setFolderId($this->getFolderId());
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Rewriting Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return RewritingPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new RewritingPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return Rewriting The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(Product $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->url = null;
+ $this->product_id = null;
+ $this->category_id = null;
+ $this->folder_id = null;
+ $this->content_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aFolder = null;
+ $this->aContent = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(RewritingPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseRewritingPeer.php b/core/lib/Thelia/Model/om/BaseRewritingPeer.php
new file mode 100644
index 000000000..c935e9c26
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseRewritingPeer.php
@@ -0,0 +1,2173 @@
+ array ('Id', 'Url', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'url', 'productId', 'categoryId', 'folderId', 'contentId', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (RewritingPeer::ID, RewritingPeer::URL, RewritingPeer::PRODUCT_ID, RewritingPeer::CATEGORY_ID, RewritingPeer::FOLDER_ID, RewritingPeer::CONTENT_ID, RewritingPeer::CREATED_AT, RewritingPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'URL', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'url', 'product_id', 'category_id', 'folder_id', 'content_id', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. RewritingPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Url' => 1, 'ProductId' => 2, 'CategoryId' => 3, 'FolderId' => 4, 'ContentId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'url' => 1, 'productId' => 2, 'categoryId' => 3, 'folderId' => 4, 'contentId' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ BasePeer::TYPE_COLNAME => array (RewritingPeer::ID => 0, RewritingPeer::URL => 1, RewritingPeer::PRODUCT_ID => 2, RewritingPeer::CATEGORY_ID => 3, RewritingPeer::FOLDER_ID => 4, RewritingPeer::CONTENT_ID => 5, RewritingPeer::CREATED_AT => 6, RewritingPeer::UPDATED_AT => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'URL' => 1, 'PRODUCT_ID' => 2, 'CATEGORY_ID' => 3, 'FOLDER_ID' => 4, 'CONTENT_ID' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'url' => 1, 'product_id' => 2, 'category_id' => 3, 'folder_id' => 4, 'content_id' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = RewritingPeer::getFieldNames($toType);
+ $key = isset(RewritingPeer::$fieldKeys[$fromType][$name]) ? RewritingPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(RewritingPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, RewritingPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return RewritingPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. RewritingPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(RewritingPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(RewritingPeer::ID);
+ $criteria->addSelectColumn(RewritingPeer::URL);
+ $criteria->addSelectColumn(RewritingPeer::PRODUCT_ID);
+ $criteria->addSelectColumn(RewritingPeer::CATEGORY_ID);
+ $criteria->addSelectColumn(RewritingPeer::FOLDER_ID);
+ $criteria->addSelectColumn(RewritingPeer::CONTENT_ID);
+ $criteria->addSelectColumn(RewritingPeer::CREATED_AT);
+ $criteria->addSelectColumn(RewritingPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.URL');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Rewriting
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = RewritingPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return RewritingPeer::populateObjects(RewritingPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ RewritingPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Rewriting $obj A Rewriting object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ RewritingPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Rewriting object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Rewriting) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Rewriting object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(RewritingPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Rewriting Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(RewritingPeer::$instances[$key])) {
+ return RewritingPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ RewritingPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to rewriting
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = RewritingPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = RewritingPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = RewritingPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ RewritingPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Rewriting object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = RewritingPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + RewritingPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = RewritingPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ RewritingPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(RewritingPeer::DATABASE_NAME)->getTable(RewritingPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseRewritingPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseRewritingPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new RewritingTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return RewritingPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Rewriting or Criteria object.
+ *
+ * @param mixed $values Criteria or Rewriting object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Rewriting object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Rewriting or Criteria object.
+ *
+ * @param mixed $values Criteria or Rewriting object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(RewritingPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(RewritingPeer::ID);
+ $value = $criteria->remove(RewritingPeer::ID);
+ if ($value) {
+ $selectCriteria->add(RewritingPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(RewritingPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Rewriting object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the rewriting table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ RewritingPeer::clearInstancePool();
+ RewritingPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Rewriting or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Rewriting object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(RewritingPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ RewritingPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Rewriting object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Rewriting $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(RewritingPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(RewritingPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(RewritingPeer::DATABASE_NAME, RewritingPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Rewriting
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = RewritingPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(RewritingPeer::DATABASE_NAME);
+ $criteria->add(RewritingPeer::ID, $pk);
+
+ $v = RewritingPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Rewriting[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(RewritingPeer::DATABASE_NAME);
+ $criteria->add(RewritingPeer::ID, $pks, Criteria::IN);
+ $objs = RewritingPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseRewritingPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseRewritingPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseRewritingQuery.php b/core/lib/Thelia/Model/om/BaseRewritingQuery.php
new file mode 100644
index 000000000..e2e0c3066
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseRewritingQuery.php
@@ -0,0 +1,898 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Rewriting|Rewriting[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = RewritingPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Rewriting A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `URL`, `PRODUCT_ID`, `CATEGORY_ID`, `FOLDER_ID`, `CONTENT_ID`, `CREATED_AT`, `UPDATED_AT` FROM `rewriting` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Rewriting();
+ $obj->hydrate($row);
+ RewritingPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Rewriting|Rewriting[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Rewriting[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(RewritingPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(RewritingPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(RewritingPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the url column
+ *
+ * Example usage:
+ *
+ * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue'
+ * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%'
+ *
+ *
+ * @param string $url The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByUrl($url = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($url)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $url)) {
+ $url = str_replace('*', '%', $url);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingPeer::URL, $url, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(RewritingPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(RewritingPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingPeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(RewritingPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(RewritingPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingPeer::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId)) {
+ $useMinMax = false;
+ if (isset($folderId['min'])) {
+ $this->addUsingAlias(RewritingPeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($folderId['max'])) {
+ $this->addUsingAlias(RewritingPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingPeer::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(RewritingPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(RewritingPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingPeer::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(RewritingPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(RewritingPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(RewritingPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(RewritingPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingPeer::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 RewritingQuery 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(RewritingPeer::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(RewritingPeer::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 RewritingQuery 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 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
+ *
+ * @param Rewriting $rewriting Object to remove from the list of results
+ *
+ * @return RewritingQuery The current query, for fluid interface
+ */
+ public function prune($rewriting = null)
+ {
+ if ($rewriting) {
+ $this->addUsingAlias(RewritingPeer::ID, $rewriting->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseStock.php b/core/lib/Thelia/Model/om/BaseStock.php
new file mode 100644
index 000000000..1eb1c7c68
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseStock.php
@@ -0,0 +1,1348 @@
+id;
+ }
+
+ /**
+ * Get the [combination_id] column value.
+ *
+ * @return int
+ */
+ public function getCombinationId()
+ {
+ return $this->combination_id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [increase] column value.
+ *
+ * @return double
+ */
+ public function getIncrease()
+ {
+ return $this->increase;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return double
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Stock The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = StockPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [combination_id] column.
+ *
+ * @param int $v new value
+ * @return Stock The current object (for fluent API support)
+ */
+ public function setCombinationId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->combination_id !== $v) {
+ $this->combination_id = $v;
+ $this->modifiedColumns[] = StockPeer::COMBINATION_ID;
+ }
+
+ if ($this->aCombination !== null && $this->aCombination->getId() !== $v) {
+ $this->aCombination = null;
+ }
+
+
+ return $this;
+ } // setCombinationId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return Stock The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = StockPeer::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [increase] column.
+ *
+ * @param double $v new value
+ * @return Stock The current object (for fluent API support)
+ */
+ public function setIncrease($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->increase !== $v) {
+ $this->increase = $v;
+ $this->modifiedColumns[] = StockPeer::INCREASE;
+ }
+
+
+ return $this;
+ } // setIncrease()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param double $v new value
+ * @return Stock The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = StockPeer::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Stock The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = StockPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Stock The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = StockPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->combination_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->product_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->increase = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null;
+ $this->value = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = StockPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Stock object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = StockPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCombination = null;
+ $this->aProduct = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = StockQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ StockPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = StockPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . StockPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(StockPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(StockPeer::COMBINATION_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COMBINATION_ID`';
+ }
+ if ($this->isColumnModified(StockPeer::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`';
+ }
+ if ($this->isColumnModified(StockPeer::INCREASE)) {
+ $modifiedColumns[':p' . $index++] = '`INCREASE`';
+ }
+ if ($this->isColumnModified(StockPeer::VALUE)) {
+ $modifiedColumns[':p' . $index++] = '`VALUE`';
+ }
+ if ($this->isColumnModified(StockPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(StockPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `stock` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`COMBINATION_ID`':
+ $stmt->bindValue($identifier, $this->combination_id, PDO::PARAM_INT);
+ break;
+ case '`PRODUCT_ID`':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case '`INCREASE`':
+ $stmt->bindValue($identifier, $this->increase, PDO::PARAM_STR);
+ break;
+ case '`VALUE`':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = StockPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCombinationId();
+ break;
+ case 2:
+ return $this->getProductId();
+ break;
+ case 3:
+ return $this->getIncrease();
+ break;
+ case 4:
+ return $this->getValue();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Stock'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Stock'][$this->getPrimaryKey()] = true;
+ $keys = StockPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCombinationId(),
+ $keys[2] => $this->getProductId(),
+ $keys[3] => $this->getIncrease(),
+ $keys[4] => $this->getValue(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aCombination) {
+ $result['Combination'] = $this->aCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = StockPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCombinationId($value);
+ break;
+ case 2:
+ $this->setProductId($value);
+ break;
+ case 3:
+ $this->setIncrease($value);
+ break;
+ case 4:
+ $this->setValue($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = StockPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCombinationId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setIncrease($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setValue($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(StockPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(StockPeer::ID)) $criteria->add(StockPeer::ID, $this->id);
+ if ($this->isColumnModified(StockPeer::COMBINATION_ID)) $criteria->add(StockPeer::COMBINATION_ID, $this->combination_id);
+ if ($this->isColumnModified(StockPeer::PRODUCT_ID)) $criteria->add(StockPeer::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(StockPeer::INCREASE)) $criteria->add(StockPeer::INCREASE, $this->increase);
+ if ($this->isColumnModified(StockPeer::VALUE)) $criteria->add(StockPeer::VALUE, $this->value);
+ if ($this->isColumnModified(StockPeer::CREATED_AT)) $criteria->add(StockPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(StockPeer::UPDATED_AT)) $criteria->add(StockPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(StockPeer::DATABASE_NAME);
+ $criteria->add(StockPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Stock (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCombinationId($this->getCombinationId());
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setIncrease($this->getIncrease());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Stock Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return StockPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new StockPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Combination object.
+ *
+ * @param Combination $v
+ * @return Stock The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCombination(Combination $v = null)
+ {
+ 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;
+ }
+
+
+ /**
+ * 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->addStocks($this);
+ */
+ }
+
+ return $this->aCombination;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return Stock The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(Product $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->combination_id = null;
+ $this->product_id = null;
+ $this->increase = null;
+ $this->value = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCombination = null;
+ $this->aProduct = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(StockPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseStockPeer.php b/core/lib/Thelia/Model/om/BaseStockPeer.php
new file mode 100644
index 000000000..c8fcb2e8f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseStockPeer.php
@@ -0,0 +1,1426 @@
+ array ('Id', 'CombinationId', 'ProductId', 'Increase', 'Value', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'combinationId', 'productId', 'increase', 'value', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (StockPeer::ID, StockPeer::COMBINATION_ID, StockPeer::PRODUCT_ID, StockPeer::INCREASE, StockPeer::VALUE, StockPeer::CREATED_AT, StockPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'COMBINATION_ID', 'PRODUCT_ID', 'INCREASE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'combination_id', 'product_id', 'increase', 'value', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. StockPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CombinationId' => 1, 'ProductId' => 2, 'Increase' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'combinationId' => 1, 'productId' => 2, 'increase' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (StockPeer::ID => 0, StockPeer::COMBINATION_ID => 1, StockPeer::PRODUCT_ID => 2, StockPeer::INCREASE => 3, StockPeer::VALUE => 4, StockPeer::CREATED_AT => 5, StockPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'COMBINATION_ID' => 1, 'PRODUCT_ID' => 2, 'INCREASE' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'combination_id' => 1, 'product_id' => 2, 'increase' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = StockPeer::getFieldNames($toType);
+ $key = isset(StockPeer::$fieldKeys[$fromType][$name]) ? StockPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(StockPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, StockPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return StockPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. StockPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(StockPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(StockPeer::ID);
+ $criteria->addSelectColumn(StockPeer::COMBINATION_ID);
+ $criteria->addSelectColumn(StockPeer::PRODUCT_ID);
+ $criteria->addSelectColumn(StockPeer::INCREASE);
+ $criteria->addSelectColumn(StockPeer::VALUE);
+ $criteria->addSelectColumn(StockPeer::CREATED_AT);
+ $criteria->addSelectColumn(StockPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.COMBINATION_ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.INCREASE');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(StockPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Stock
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = StockPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return StockPeer::populateObjects(StockPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ StockPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Stock $obj A Stock object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ StockPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Stock object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Stock) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Stock object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(StockPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Stock Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(StockPeer::$instances[$key])) {
+ return StockPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ StockPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to stock
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = StockPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = StockPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = StockPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ StockPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Stock object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = StockPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = StockPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + StockPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = StockPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ StockPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(StockPeer::DATABASE_NAME)->getTable(StockPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseStockPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseStockPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new StockTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return StockPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Stock or Criteria object.
+ *
+ * @param mixed $values Criteria or Stock object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Stock object
+ }
+
+ if ($criteria->containsKey(StockPeer::ID) && $criteria->keyContainsValue(StockPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.StockPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Stock or Criteria object.
+ *
+ * @param mixed $values Criteria or Stock object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(StockPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(StockPeer::ID);
+ $value = $criteria->remove(StockPeer::ID);
+ if ($value) {
+ $selectCriteria->add(StockPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(StockPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Stock object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the stock table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ StockPeer::clearInstancePool();
+ StockPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Stock or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Stock object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(StockPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ StockPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Stock object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Stock $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(StockPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(StockPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(StockPeer::DATABASE_NAME, StockPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Stock
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = StockPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(StockPeer::DATABASE_NAME);
+ $criteria->add(StockPeer::ID, $pk);
+
+ $v = StockPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Stock[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(StockPeer::DATABASE_NAME);
+ $criteria->add(StockPeer::ID, $pks, Criteria::IN);
+ $objs = StockPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseStockPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseStockPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseStockQuery.php b/core/lib/Thelia/Model/om/BaseStockQuery.php
new file mode 100644
index 000000000..916de2f0f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseStockQuery.php
@@ -0,0 +1,699 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Stock|Stock[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = StockPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Stock A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `COMBINATION_ID`, `PRODUCT_ID`, `INCREASE`, `VALUE`, `CREATED_AT`, `UPDATED_AT` FROM `stock` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Stock();
+ $obj->hydrate($row);
+ StockPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Stock|Stock[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Stock[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(StockPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(StockPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(StockPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the combination_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCombinationId(1234); // WHERE combination_id = 1234
+ * $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34)
+ * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12
+ *
+ *
+ * @see filterByCombination()
+ *
+ * @param mixed $combinationId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterByCombinationId($combinationId = null, $comparison = null)
+ {
+ if (is_array($combinationId)) {
+ $useMinMax = false;
+ if (isset($combinationId['min'])) {
+ $this->addUsingAlias(StockPeer::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($combinationId['max'])) {
+ $this->addUsingAlias(StockPeer::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockPeer::COMBINATION_ID, $combinationId, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(StockPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(StockPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockPeer::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the increase column
+ *
+ * Example usage:
+ *
+ * $query->filterByIncrease(1234); // WHERE increase = 1234
+ * $query->filterByIncrease(array(12, 34)); // WHERE increase IN (12, 34)
+ * $query->filterByIncrease(array('min' => 12)); // WHERE increase > 12
+ *
+ *
+ * @param mixed $increase The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterByIncrease($increase = null, $comparison = null)
+ {
+ if (is_array($increase)) {
+ $useMinMax = false;
+ if (isset($increase['min'])) {
+ $this->addUsingAlias(StockPeer::INCREASE, $increase['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($increase['max'])) {
+ $this->addUsingAlias(StockPeer::INCREASE, $increase['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockPeer::INCREASE, $increase, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue(1234); // WHERE value = 1234
+ * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
+ * $query->filterByValue(array('min' => 12)); // WHERE value > 12
+ *
+ *
+ * @param mixed $value The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (is_array($value)) {
+ $useMinMax = false;
+ if (isset($value['min'])) {
+ $this->addUsingAlias(StockPeer::VALUE, $value['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($value['max'])) {
+ $this->addUsingAlias(StockPeer::VALUE, $value['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockPeer::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(StockPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(StockPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(StockPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(StockPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Combination object
+ *
+ * @param Combination|PropelObjectCollection $combination The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return StockQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCombination($combination, $comparison = null)
+ {
+ if ($combination instanceof Combination) {
+ return $this
+ ->addUsingAlias(StockPeer::COMBINATION_ID, $combination->getId(), $comparison);
+ } elseif ($combination instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(StockPeer::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCombination() only accepts arguments of type Combination or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Combination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function joinCombination($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Combination');
+
+ // 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, 'Combination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Combination relation Combination 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\CombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useCombinationQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Combination', '\Thelia\Model\CombinationQuery');
+ }
+
+ /**
+ * 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 StockQuery 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(StockPeer::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(StockPeer::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 StockQuery 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
+ *
+ * @param Stock $stock Object to remove from the list of results
+ *
+ * @return StockQuery The current query, for fluid interface
+ */
+ public function prune($stock = null)
+ {
+ if ($stock) {
+ $this->addUsingAlias(StockPeer::ID, $stock->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTax.php b/core/lib/Thelia/Model/om/BaseTax.php
new file mode 100644
index 000000000..88132e987
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTax.php
@@ -0,0 +1,1610 @@
+id;
+ }
+
+ /**
+ * Get the [rate] column value.
+ *
+ * @return double
+ */
+ public function getRate()
+ {
+ return $this->rate;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return Tax The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [rate] column.
+ *
+ * @param double $v new value
+ * @return Tax The current object (for fluent API support)
+ */
+ public function setRate($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->rate !== $v) {
+ $this->rate = $v;
+ $this->modifiedColumns[] = TaxPeer::RATE;
+ }
+
+
+ return $this;
+ } // setRate()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Tax The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return Tax The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->rate = ($row[$startcol + 1] !== null) ? (double) $row[$startcol + 1] : null;
+ $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = TaxPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Tax object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = TaxPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collTaxDescs = null;
+
+ $this->collTaxRuleCountrys = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = TaxQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = TaxPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(TaxPeer::RATE)) {
+ $modifiedColumns[':p' . $index++] = '`RATE`';
+ }
+ if ($this->isColumnModified(TaxPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(TaxPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `tax` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`RATE`':
+ $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getRate();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Tax'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Tax'][$this->getPrimaryKey()] = true;
+ $keys = TaxPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRate(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collTaxDescs) {
+ $result['TaxDescs'] = $this->collTaxDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collTaxRuleCountrys) {
+ $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setRate($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = TaxPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRate($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(TaxPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxPeer::ID)) $criteria->add(TaxPeer::ID, $this->id);
+ if ($this->isColumnModified(TaxPeer::RATE)) $criteria->add(TaxPeer::RATE, $this->rate);
+ if ($this->isColumnModified(TaxPeer::CREATED_AT)) $criteria->add(TaxPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(TaxPeer::UPDATED_AT)) $criteria->add(TaxPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(TaxPeer::DATABASE_NAME);
+ $criteria->add(TaxPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of Tax (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRate($this->getRate());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ foreach ($this->getTaxRuleCountrys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxRuleCountry($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return Tax Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return TaxPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new TaxPeer();
+ }
+
+ 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.
+ *
+ * @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 getTaxDescs($criteria = null, PropelPDO $con = 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 {
+ return count($this->collTaxDescs);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param TaxDesc $taxDesc The taxDesc object to add.
+ */
+ protected function doAddTaxDesc($taxDesc)
+ {
+ $this->collTaxDescs[]= $taxDesc;
+ $taxDesc->setTax($this);
+ }
+
+ /**
+ * @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
+ *
+ * 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 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)
+ ->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 {
+ 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 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);
+ }
+
+ /**
+ * @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->setTax(null);
+ }
+ }
+
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->rate = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ if ($this->collTaxDescs instanceof PropelCollection) {
+ $this->collTaxDescs->clearIterator();
+ }
+ $this->collTaxDescs = null;
+ if ($this->collTaxRuleCountrys instanceof PropelCollection) {
+ $this->collTaxRuleCountrys->clearIterator();
+ }
+ $this->collTaxRuleCountrys = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxDesc.php b/core/lib/Thelia/Model/om/BaseTaxDesc.php
new file mode 100644
index 000000000..babd76e97
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxDesc.php
@@ -0,0 +1,1265 @@
+id;
+ }
+
+ /**
+ * Get the [tax_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxId()
+ {
+ return $this->tax_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return TaxDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [tax_id] column.
+ *
+ * @param int $v new value
+ * @return TaxDesc The current object (for fluent API support)
+ */
+ public function setTaxId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_id !== $v) {
+ $this->tax_id = $v;
+ $this->modifiedColumns[] = TaxDescPeer::TAX_ID;
+ }
+
+ if ($this->aTax !== null && $this->aTax->getId() !== $v) {
+ $this->aTax = null;
+ }
+
+
+ return $this;
+ } // setTaxId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return TaxDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = TaxDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return TaxDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = TaxDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return TaxDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = TaxDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return TaxDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return TaxDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->tax_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = TaxDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating TaxDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aTax !== null && $this->tax_id !== $this->aTax->getId()) {
+ $this->aTax = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = TaxDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aTax = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = TaxDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = TaxDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(TaxDescPeer::TAX_ID)) {
+ $modifiedColumns[':p' . $index++] = '`TAX_ID`';
+ }
+ if ($this->isColumnModified(TaxDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(TaxDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(TaxDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(TaxDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(TaxDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `tax_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`TAX_ID`':
+ $stmt->bindValue($identifier, $this->tax_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getTaxId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['TaxDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['TaxDesc'][$this->getPrimaryKey()] = true;
+ $keys = TaxDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTaxId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aTax) {
+ $result['Tax'] = $this->aTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setTaxId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = TaxDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTaxId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(TaxDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxDescPeer::ID)) $criteria->add(TaxDescPeer::ID, $this->id);
+ if ($this->isColumnModified(TaxDescPeer::TAX_ID)) $criteria->add(TaxDescPeer::TAX_ID, $this->tax_id);
+ if ($this->isColumnModified(TaxDescPeer::LANG)) $criteria->add(TaxDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(TaxDescPeer::TITLE)) $criteria->add(TaxDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(TaxDescPeer::DESCRIPTION)) $criteria->add(TaxDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(TaxDescPeer::CREATED_AT)) $criteria->add(TaxDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(TaxDescPeer::UPDATED_AT)) $criteria->add(TaxDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(TaxDescPeer::DATABASE_NAME);
+ $criteria->add(TaxDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of TaxDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTaxId($this->getTaxId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return TaxDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return TaxDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new TaxDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Tax object.
+ *
+ * @param Tax $v
+ * @return TaxDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTax(Tax $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->tax_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aTax = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxDescPeer.php b/core/lib/Thelia/Model/om/BaseTaxDescPeer.php
new file mode 100644
index 000000000..aecfb3a76
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxDescPeer.php
@@ -0,0 +1,1032 @@
+ array ('Id', 'TaxId', 'Lang', 'Title', 'Description', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxId', 'lang', 'title', 'description', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (TaxDescPeer::ID, TaxDescPeer::TAX_ID, TaxDescPeer::LANG, TaxDescPeer::TITLE, TaxDescPeer::DESCRIPTION, TaxDescPeer::CREATED_AT, TaxDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'tax_id', 'lang', 'title', 'description', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. TaxDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (TaxDescPeer::ID => 0, TaxDescPeer::TAX_ID => 1, TaxDescPeer::LANG => 2, TaxDescPeer::TITLE => 3, TaxDescPeer::DESCRIPTION => 4, TaxDescPeer::CREATED_AT => 5, TaxDescPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = TaxDescPeer::getFieldNames($toType);
+ $key = isset(TaxDescPeer::$fieldKeys[$fromType][$name]) ? TaxDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(TaxDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, TaxDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return TaxDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. TaxDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(TaxDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxDescPeer::ID);
+ $criteria->addSelectColumn(TaxDescPeer::TAX_ID);
+ $criteria->addSelectColumn(TaxDescPeer::LANG);
+ $criteria->addSelectColumn(TaxDescPeer::TITLE);
+ $criteria->addSelectColumn(TaxDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(TaxDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(TaxDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TAX_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return TaxDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = TaxDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return TaxDescPeer::populateObjects(TaxDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ TaxDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param TaxDesc $obj A TaxDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ TaxDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A TaxDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof TaxDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or TaxDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(TaxDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return TaxDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(TaxDescPeer::$instances[$key])) {
+ return TaxDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ TaxDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to tax_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = TaxDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = TaxDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = TaxDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (TaxDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = TaxDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = TaxDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + TaxDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ TaxDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(TaxDescPeer::DATABASE_NAME)->getTable(TaxDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseTaxDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseTaxDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return TaxDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a TaxDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or TaxDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from TaxDesc object
+ }
+
+ if ($criteria->containsKey(TaxDescPeer::ID) && $criteria->keyContainsValue(TaxDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a TaxDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or TaxDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(TaxDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(TaxDescPeer::ID);
+ $value = $criteria->remove(TaxDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(TaxDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(TaxDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is TaxDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the tax_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ TaxDescPeer::clearInstancePool();
+ TaxDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a TaxDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or TaxDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(TaxDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ TaxDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given TaxDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param TaxDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(TaxDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(TaxDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(TaxDescPeer::DATABASE_NAME, TaxDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return TaxDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = TaxDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(TaxDescPeer::DATABASE_NAME);
+ $criteria->add(TaxDescPeer::ID, $pk);
+
+ $v = TaxDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return TaxDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(TaxDescPeer::DATABASE_NAME);
+ $criteria->add(TaxDescPeer::ID, $pks, Criteria::IN);
+ $objs = TaxDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseTaxDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseTaxDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseTaxDescQuery.php b/core/lib/Thelia/Model/om/BaseTaxDescQuery.php
new file mode 100644
index 000000000..f7c774672
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxDescQuery.php
@@ -0,0 +1,580 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return TaxDesc|TaxDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(TaxDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return TaxDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `TAX_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CREATED_AT`, `UPDATED_AT` FROM `tax_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new TaxDesc();
+ $obj->hydrate($row);
+ TaxDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return TaxDesc|TaxDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|TaxDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(TaxDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(TaxDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(TaxDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxId(1234); // WHERE tax_id = 1234
+ * $query->filterByTaxId(array(12, 34)); // WHERE tax_id IN (12, 34)
+ * $query->filterByTaxId(array('min' => 12)); // WHERE tax_id > 12
+ *
+ *
+ * @see filterByTax()
+ *
+ * @param mixed $taxId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterByTaxId($taxId = null, $comparison = null)
+ {
+ if (is_array($taxId)) {
+ $useMinMax = false;
+ if (isset($taxId['min'])) {
+ $this->addUsingAlias(TaxDescPeer::TAX_ID, $taxId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxId['max'])) {
+ $this->addUsingAlias(TaxDescPeer::TAX_ID, $taxId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxDescPeer::TAX_ID, $taxId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(TaxDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(TaxDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(TaxDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(TaxDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Tax object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTax($tax, $comparison = null)
+ {
+ if ($tax instanceof Tax) {
+ return $this
+ ->addUsingAlias(TaxDescPeer::TAX_ID, $tax->getId(), $comparison);
+ } elseif ($tax instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxDescPeer::TAX_ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Tax relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function joinTax($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Tax');
+
+ // 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, 'Tax');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Tax relation Tax 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\TaxQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinTax($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Tax', '\Thelia\Model\TaxQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param TaxDesc $taxDesc Object to remove from the list of results
+ *
+ * @return TaxDescQuery The current query, for fluid interface
+ */
+ public function prune($taxDesc = null)
+ {
+ if ($taxDesc) {
+ $this->addUsingAlias(TaxDescPeer::ID, $taxDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxPeer.php b/core/lib/Thelia/Model/om/BaseTaxPeer.php
new file mode 100644
index 000000000..1615d0f4c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxPeer.php
@@ -0,0 +1,786 @@
+ array ('Id', 'Rate', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'rate', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (TaxPeer::ID, TaxPeer::RATE, TaxPeer::CREATED_AT, TaxPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'RATE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'rate', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. TaxPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Rate' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'rate' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ BasePeer::TYPE_COLNAME => array (TaxPeer::ID => 0, TaxPeer::RATE => 1, TaxPeer::CREATED_AT => 2, TaxPeer::UPDATED_AT => 3, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'RATE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'rate' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = TaxPeer::getFieldNames($toType);
+ $key = isset(TaxPeer::$fieldKeys[$fromType][$name]) ? TaxPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(TaxPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, TaxPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return TaxPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. TaxPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(TaxPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxPeer::ID);
+ $criteria->addSelectColumn(TaxPeer::RATE);
+ $criteria->addSelectColumn(TaxPeer::CREATED_AT);
+ $criteria->addSelectColumn(TaxPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.RATE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(TaxPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return Tax
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = TaxPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return TaxPeer::populateObjects(TaxPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ TaxPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param Tax $obj A Tax object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ TaxPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A Tax object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof Tax) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Tax object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(TaxPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return Tax Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(TaxPeer::$instances[$key])) {
+ return TaxPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ TaxPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to tax
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = TaxPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = TaxPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = TaxPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Tax object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = TaxPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + TaxPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ TaxPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(TaxPeer::DATABASE_NAME)->getTable(TaxPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseTaxPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseTaxPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return TaxPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Tax or Criteria object.
+ *
+ * @param mixed $values Criteria or Tax object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from Tax object
+ }
+
+ if ($criteria->containsKey(TaxPeer::ID) && $criteria->keyContainsValue(TaxPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a Tax or Criteria object.
+ *
+ * @param mixed $values Criteria or Tax object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(TaxPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(TaxPeer::ID);
+ $value = $criteria->remove(TaxPeer::ID);
+ if ($value) {
+ $selectCriteria->add(TaxPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(TaxPeer::TABLE_NAME);
+ }
+
+ } else { // $values is Tax object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(TaxPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the tax table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(TaxPeer::TABLE_NAME, $con, TaxPeer::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
+ // instances get re-added by the select statement contained therein).
+ TaxPeer::clearInstancePool();
+ TaxPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Tax or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Tax object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ TaxPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof Tax) { // it's a model object
+ // invalidate the cache for this single object
+ TaxPeer::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(TaxPeer::DATABASE_NAME);
+ $criteria->add(TaxPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ TaxPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ TaxPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given Tax object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param Tax $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(TaxPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(TaxPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(TaxPeer::DATABASE_NAME, TaxPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return Tax
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = TaxPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(TaxPeer::DATABASE_NAME);
+ $criteria->add(TaxPeer::ID, $pk);
+
+ $v = TaxPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return Tax[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(TaxPeer::DATABASE_NAME);
+ $criteria->add(TaxPeer::ID, $pks, Criteria::IN);
+ $objs = TaxPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseTaxPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseTaxPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseTaxQuery.php b/core/lib/Thelia/Model/om/BaseTaxQuery.php
new file mode 100644
index 000000000..f28d71d01
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxQuery.php
@@ -0,0 +1,556 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return Tax|Tax[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Tax A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `RATE`, `CREATED_AT`, `UPDATED_AT` FROM `tax` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new Tax();
+ $obj->hydrate($row);
+ TaxPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return Tax|Tax[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|Tax[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(TaxPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(TaxPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(TaxPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the rate column
+ *
+ * Example usage:
+ *
+ * $query->filterByRate(1234); // WHERE rate = 1234
+ * $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34)
+ * $query->filterByRate(array('min' => 12)); // WHERE rate > 12
+ *
+ *
+ * @param mixed $rate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function filterByRate($rate = null, $comparison = null)
+ {
+ if (is_array($rate)) {
+ $useMinMax = false;
+ if (isset($rate['min'])) {
+ $this->addUsingAlias(TaxPeer::RATE, $rate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($rate['max'])) {
+ $this->addUsingAlias(TaxPeer::RATE, $rate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxPeer::RATE, $rate, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(TaxPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(TaxPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(TaxPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(TaxPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related TaxDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTaxDesc($taxDesc, $comparison = null)
+ {
+ if ($taxDesc instanceof TaxDesc) {
+ return $this
+ ->addUsingAlias(TaxPeer::ID, $taxDesc->getTaxId(), $comparison);
+ } elseif ($taxDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useTaxDescQuery()
+ ->filterByPrimaryKeys($taxDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxDesc() only accepts arguments of type TaxDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function joinTaxDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxDesc');
+
+ // 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, 'TaxDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxDesc relation TaxDesc 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\TaxDescQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinTaxDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxDesc', '\Thelia\Model\TaxDescQuery');
+ }
+
+ /**
+ * Filter the query by a related TaxRuleCountry object
+ *
+ * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null)
+ {
+ if ($taxRuleCountry instanceof TaxRuleCountry) {
+ return $this
+ ->addUsingAlias(TaxPeer::ID, $taxRuleCountry->getTaxId(), $comparison);
+ } elseif ($taxRuleCountry instanceof PropelObjectCollection) {
+ return $this
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRuleCountry relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRuleCountry');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRuleCountry');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRuleCountry relation TaxRuleCountry object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRuleCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param Tax $tax Object to remove from the list of results
+ *
+ * @return TaxQuery The current query, for fluid interface
+ */
+ public function prune($tax = null)
+ {
+ if ($tax) {
+ $this->addUsingAlias(TaxPeer::ID, $tax->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxRule.php b/core/lib/Thelia/Model/om/BaseTaxRule.php
new file mode 100644
index 000000000..3652824ce
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRule.php
@@ -0,0 +1,1881 @@
+id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return TaxRule The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxRulePeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return TaxRule The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = TaxRulePeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return TaxRule The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxRulePeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return TaxRule The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxRulePeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = TaxRulePeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating TaxRule object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = TaxRulePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collProducts = null;
+
+ $this->collTaxRuleCountrys = null;
+
+ $this->collTaxRuleDescs = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = TaxRuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxRulePeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $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;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = TaxRulePeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxRulePeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxRulePeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(TaxRulePeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(TaxRulePeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(TaxRulePeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `tax_rule` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`CODE`':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ 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;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getCode();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['TaxRule'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['TaxRule'][$this->getPrimaryKey()] = true;
+ $keys = TaxRulePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->collProducts) {
+ $result['Products'] = $this->collProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collTaxRuleCountrys) {
+ $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collTaxRuleDescs) {
+ $result['TaxRuleDescs'] = $this->collTaxRuleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setCode($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = TaxRulePeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(TaxRulePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxRulePeer::ID)) $criteria->add(TaxRulePeer::ID, $this->id);
+ if ($this->isColumnModified(TaxRulePeer::CODE)) $criteria->add(TaxRulePeer::CODE, $this->code);
+ if ($this->isColumnModified(TaxRulePeer::CREATED_AT)) $criteria->add(TaxRulePeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(TaxRulePeer::UPDATED_AT)) $criteria->add(TaxRulePeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(TaxRulePeer::DATABASE_NAME);
+ $criteria->add(TaxRulePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of TaxRule (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ 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));
+ }
+ }
+
+ foreach ($this->getTaxRuleCountrys() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxRuleCountry($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getTaxRuleDescs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxRuleDesc($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return TaxRule Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return TaxRulePeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new TaxRulePeer();
+ }
+
+ 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.
+ *
+ * @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 getProducts($criteria = null, PropelPDO $con = 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 {
+ return count($this->collProducts);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @param Product $product The product object to add.
+ */
+ protected function doAddProduct($product)
+ {
+ $this->collProducts[]= $product;
+ $product->setTaxRule($this);
+ }
+
+ /**
+ * @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
+ *
+ * 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 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)
+ ->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 {
+ 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 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;
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add.
+ */
+ protected function doAddTaxRuleCountry($taxRuleCountry)
+ {
+ $this->collTaxRuleCountrys[]= $taxRuleCountry;
+ $taxRuleCountry->setTaxRule($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->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.
+ *
+ * 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 getTaxRuleDescs($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collTaxRuleDescsPartial && !$this->isNew();
+ if (null === $this->collTaxRuleDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleDescs) {
+ // return empty collection
+ $this->initTaxRuleDescs();
+ } else {
+ $collTaxRuleDescs = TaxRuleDescQuery::create(null, $criteria)
+ ->filterByTaxRule($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collTaxRuleDescsPartial && count($collTaxRuleDescs)) {
+ $this->initTaxRuleDescs(false);
+
+ foreach($collTaxRuleDescs as $obj) {
+ if (false == $this->collTaxRuleDescs->contains($obj)) {
+ $this->collTaxRuleDescs->append($obj);
+ }
+ }
+
+ $this->collTaxRuleDescsPartial = true;
+ }
+
+ return $collTaxRuleDescs;
+ }
+
+ if($partial && $this->collTaxRuleDescs) {
+ foreach($this->collTaxRuleDescs as $obj) {
+ if($obj->isNew()) {
+ $collTaxRuleDescs[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxRuleDescs = $collTaxRuleDescs;
+ $this->collTaxRuleDescsPartial = false;
+ }
+ }
+
+ return $this->collTaxRuleDescs;
+ }
+
+ /**
+ * Sets a collection of TaxRuleDesc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $taxRuleDescs A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setTaxRuleDescs(PropelCollection $taxRuleDescs, PropelPDO $con = null)
+ {
+ $this->taxRuleDescsScheduledForDeletion = $this->getTaxRuleDescs(new Criteria(), $con)->diff($taxRuleDescs);
+
+ foreach ($this->taxRuleDescsScheduledForDeletion as $taxRuleDescRemoved) {
+ $taxRuleDescRemoved->setTaxRule(null);
+ }
+
+ $this->collTaxRuleDescs = null;
+ foreach ($taxRuleDescs as $taxRuleDesc) {
+ $this->addTaxRuleDesc($taxRuleDesc);
+ }
+
+ $this->collTaxRuleDescs = $taxRuleDescs;
+ $this->collTaxRuleDescsPartial = false;
+ }
+
+ /**
+ * Returns the number of related TaxRuleDesc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related TaxRuleDesc objects.
+ * @throws PropelException
+ */
+ public function countTaxRuleDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collTaxRuleDescsPartial && !$this->isNew();
+ if (null === $this->collTaxRuleDescs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleDescs) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getTaxRuleDescs());
+ }
+ $query = TaxRuleDescQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTaxRule($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collTaxRuleDescs);
+ }
+ }
+
+ /**
+ * Method called to associate a TaxRuleDesc object to this object
+ * through the TaxRuleDesc foreign key attribute.
+ *
+ * @param TaxRuleDesc $l TaxRuleDesc
+ * @return TaxRule The current object (for fluent API support)
+ */
+ public function addTaxRuleDesc(TaxRuleDesc $l)
+ {
+ if ($this->collTaxRuleDescs === null) {
+ $this->initTaxRuleDescs();
+ $this->collTaxRuleDescsPartial = true;
+ }
+ if (!$this->collTaxRuleDescs->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxRuleDesc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param TaxRuleDesc $taxRuleDesc The taxRuleDesc object to add.
+ */
+ protected function doAddTaxRuleDesc($taxRuleDesc)
+ {
+ $this->collTaxRuleDescs[]= $taxRuleDesc;
+ $taxRuleDesc->setTaxRule($this);
+ }
+
+ /**
+ * @param TaxRuleDesc $taxRuleDesc The taxRuleDesc object to remove.
+ */
+ public function removeTaxRuleDesc($taxRuleDesc)
+ {
+ if ($this->getTaxRuleDescs()->contains($taxRuleDesc)) {
+ $this->collTaxRuleDescs->remove($this->collTaxRuleDescs->search($taxRuleDesc));
+ if (null === $this->taxRuleDescsScheduledForDeletion) {
+ $this->taxRuleDescsScheduledForDeletion = clone $this->collTaxRuleDescs;
+ $this->taxRuleDescsScheduledForDeletion->clear();
+ }
+ $this->taxRuleDescsScheduledForDeletion[]= $taxRuleDesc;
+ $taxRuleDesc->setTaxRule(null);
+ }
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ 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)
+
+ 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;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxRulePeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php
new file mode 100644
index 000000000..a510c4ba2
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php
@@ -0,0 +1,1420 @@
+id;
+ }
+
+ /**
+ * Get the [tax_rule_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxRuleId()
+ {
+ return $this->tax_rule_id;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [tax_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxId()
+ {
+ return $this->tax_id;
+ }
+
+ /**
+ * Get the [none] column value.
+ *
+ * @return int
+ */
+ public function getNone()
+ {
+ return $this->none;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxRuleCountryPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [tax_rule_id] column.
+ *
+ * @param int $v new value
+ * @return TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setTaxRuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_rule_id !== $v) {
+ $this->tax_rule_id = $v;
+ $this->modifiedColumns[] = TaxRuleCountryPeer::TAX_RULE_ID;
+ }
+
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
+
+ return $this;
+ } // setTaxRuleId()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = TaxRuleCountryPeer::COUNTRY_ID;
+ }
+
+ if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
+ $this->aCountry = null;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Set the value of [tax_id] column.
+ *
+ * @param int $v new value
+ * @return TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setTaxId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_id !== $v) {
+ $this->tax_id = $v;
+ $this->modifiedColumns[] = TaxRuleCountryPeer::TAX_ID;
+ }
+
+ if ($this->aTax !== null && $this->aTax->getId() !== $v) {
+ $this->aTax = null;
+ }
+
+
+ return $this;
+ } // setTaxId()
+
+ /**
+ * Set the value of [none] column.
+ *
+ * @param int $v new value
+ * @return TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setNone($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->none !== $v) {
+ $this->none = $v;
+ $this->modifiedColumns[] = TaxRuleCountryPeer::NONE;
+ }
+
+
+ return $this;
+ } // setNone()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxRuleCountryPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxRuleCountryPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->tax_rule_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->country_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->tax_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->none = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating TaxRuleCountry object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ 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
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = TaxRuleCountryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aTax = null;
+ $this->aTaxRule = null;
+ $this->aCountry = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = TaxRuleCountryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxRuleCountryPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxRuleCountryPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(TaxRuleCountryPeer::TAX_RULE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`';
+ }
+ if ($this->isColumnModified(TaxRuleCountryPeer::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`';
+ }
+ if ($this->isColumnModified(TaxRuleCountryPeer::TAX_ID)) {
+ $modifiedColumns[':p' . $index++] = '`TAX_ID`';
+ }
+ if ($this->isColumnModified(TaxRuleCountryPeer::NONE)) {
+ $modifiedColumns[':p' . $index++] = '`NONE`';
+ }
+ if ($this->isColumnModified(TaxRuleCountryPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `tax_rule_country` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`TAX_RULE_ID`':
+ $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
+ break;
+ case '`COUNTRY_ID`':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case '`TAX_ID`':
+ $stmt->bindValue($identifier, $this->tax_id, PDO::PARAM_INT);
+ break;
+ case '`NONE`':
+ $stmt->bindValue($identifier, $this->none, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleCountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getTaxRuleId();
+ break;
+ case 2:
+ return $this->getCountryId();
+ break;
+ case 3:
+ return $this->getTaxId();
+ break;
+ case 4:
+ return $this->getNone();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['TaxRuleCountry'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['TaxRuleCountry'][$this->getPrimaryKey()] = true;
+ $keys = TaxRuleCountryPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTaxRuleId(),
+ $keys[2] => $this->getCountryId(),
+ $keys[3] => $this->getTaxId(),
+ $keys[4] => $this->getNone(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aTax) {
+ $result['Tax'] = $this->aTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCountry) {
+ $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleCountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setTaxRuleId($value);
+ break;
+ case 2:
+ $this->setCountryId($value);
+ break;
+ case 3:
+ $this->setTaxId($value);
+ break;
+ case 4:
+ $this->setNone($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = TaxRuleCountryPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCountryId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTaxId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setNone($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxRuleCountryPeer::ID)) $criteria->add(TaxRuleCountryPeer::ID, $this->id);
+ if ($this->isColumnModified(TaxRuleCountryPeer::TAX_RULE_ID)) $criteria->add(TaxRuleCountryPeer::TAX_RULE_ID, $this->tax_rule_id);
+ if ($this->isColumnModified(TaxRuleCountryPeer::COUNTRY_ID)) $criteria->add(TaxRuleCountryPeer::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(TaxRuleCountryPeer::TAX_ID)) $criteria->add(TaxRuleCountryPeer::TAX_ID, $this->tax_id);
+ if ($this->isColumnModified(TaxRuleCountryPeer::NONE)) $criteria->add(TaxRuleCountryPeer::NONE, $this->none);
+ if ($this->isColumnModified(TaxRuleCountryPeer::CREATED_AT)) $criteria->add(TaxRuleCountryPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) $criteria->add(TaxRuleCountryPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME);
+ $criteria->add(TaxRuleCountryPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of TaxRuleCountry (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTaxRuleId($this->getTaxRuleId());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setTaxId($this->getTaxId());
+ $copyObj->setNone($this->getNone());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return TaxRuleCountry Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return TaxRuleCountryPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new TaxRuleCountryPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Tax object.
+ *
+ * @param Tax $v
+ * @return TaxRuleCountry The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTax(Tax $v = null)
+ {
+ 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;
+ }
+
+
+ /**
+ * 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->addTaxRuleCountrys($this);
+ */
+ }
+
+ return $this->aTax;
+ }
+
+ /**
+ * Declares an association between this object and a TaxRule object.
+ *
+ * @param TaxRule $v
+ * @return TaxRuleCountry The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTaxRule(TaxRule $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->tax_rule_id = null;
+ $this->country_id = null;
+ $this->tax_id = null;
+ $this->none = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aTax = null;
+ $this->aTaxRule = null;
+ $this->aCountry = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxRuleCountryPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php
new file mode 100644
index 000000000..f068a8a8f
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php
@@ -0,0 +1,1769 @@
+ array ('Id', 'TaxRuleId', 'CountryId', 'TaxId', 'None', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'countryId', 'taxId', 'none', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (TaxRuleCountryPeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, TaxRuleCountryPeer::COUNTRY_ID, TaxRuleCountryPeer::TAX_ID, TaxRuleCountryPeer::NONE, TaxRuleCountryPeer::CREATED_AT, TaxRuleCountryPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'COUNTRY_ID', 'TAX_ID', 'NONE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'country_id', 'tax_id', 'none', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. TaxRuleCountryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'CountryId' => 2, 'TaxId' => 3, 'None' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'countryId' => 2, 'taxId' => 3, 'none' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (TaxRuleCountryPeer::ID => 0, TaxRuleCountryPeer::TAX_RULE_ID => 1, TaxRuleCountryPeer::COUNTRY_ID => 2, TaxRuleCountryPeer::TAX_ID => 3, TaxRuleCountryPeer::NONE => 4, TaxRuleCountryPeer::CREATED_AT => 5, TaxRuleCountryPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'COUNTRY_ID' => 2, 'TAX_ID' => 3, 'NONE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'country_id' => 2, 'tax_id' => 3, 'none' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = TaxRuleCountryPeer::getFieldNames($toType);
+ $key = isset(TaxRuleCountryPeer::$fieldKeys[$fromType][$name]) ? TaxRuleCountryPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(TaxRuleCountryPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, TaxRuleCountryPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return TaxRuleCountryPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. TaxRuleCountryPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(TaxRuleCountryPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxRuleCountryPeer::ID);
+ $criteria->addSelectColumn(TaxRuleCountryPeer::TAX_RULE_ID);
+ $criteria->addSelectColumn(TaxRuleCountryPeer::COUNTRY_ID);
+ $criteria->addSelectColumn(TaxRuleCountryPeer::TAX_ID);
+ $criteria->addSelectColumn(TaxRuleCountryPeer::NONE);
+ $criteria->addSelectColumn(TaxRuleCountryPeer::CREATED_AT);
+ $criteria->addSelectColumn(TaxRuleCountryPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_ID');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.TAX_ID');
+ $criteria->addSelectColumn($alias . '.NONE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return TaxRuleCountry
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = TaxRuleCountryPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return TaxRuleCountryPeer::populateObjects(TaxRuleCountryPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ TaxRuleCountryPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param TaxRuleCountry $obj A TaxRuleCountry object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ TaxRuleCountryPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A TaxRuleCountry object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof TaxRuleCountry) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or TaxRuleCountry object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(TaxRuleCountryPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return TaxRuleCountry Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(TaxRuleCountryPeer::$instances[$key])) {
+ return TaxRuleCountryPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ TaxRuleCountryPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to tax_rule_country
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = TaxRuleCountryPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = TaxRuleCountryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxRuleCountryPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (TaxRuleCountry object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = TaxRuleCountryPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxRuleCountryPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ TaxRuleCountryPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(TaxRuleCountryPeer::DATABASE_NAME)->getTable(TaxRuleCountryPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseTaxRuleCountryPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseTaxRuleCountryPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxRuleCountryTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return TaxRuleCountryPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a TaxRuleCountry or Criteria object.
+ *
+ * @param mixed $values Criteria or TaxRuleCountry object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from TaxRuleCountry object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a TaxRuleCountry or Criteria object.
+ *
+ * @param mixed $values Criteria or TaxRuleCountry object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(TaxRuleCountryPeer::ID);
+ $value = $criteria->remove(TaxRuleCountryPeer::ID);
+ if ($value) {
+ $selectCriteria->add(TaxRuleCountryPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME);
+ }
+
+ } else { // $values is TaxRuleCountry object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the tax_rule_country table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ TaxRuleCountryPeer::clearInstancePool();
+ TaxRuleCountryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a TaxRuleCountry or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or TaxRuleCountry object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ TaxRuleCountryPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given TaxRuleCountry object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param TaxRuleCountry $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(TaxRuleCountryPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(TaxRuleCountryPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(TaxRuleCountryPeer::DATABASE_NAME, TaxRuleCountryPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return TaxRuleCountry
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = TaxRuleCountryPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME);
+ $criteria->add(TaxRuleCountryPeer::ID, $pk);
+
+ $v = TaxRuleCountryPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return TaxRuleCountry[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME);
+ $criteria->add(TaxRuleCountryPeer::ID, $pks, Criteria::IN);
+ $objs = TaxRuleCountryPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseTaxRuleCountryPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseTaxRuleCountryPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php
new file mode 100644
index 000000000..37af55fe7
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php
@@ -0,0 +1,782 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return TaxRuleCountry|TaxRuleCountry[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxRuleCountryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return TaxRuleCountry A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `TAX_RULE_ID`, `COUNTRY_ID`, `TAX_ID`, `NONE`, `CREATED_AT`, `UPDATED_AT` FROM `tax_rule_country` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new TaxRuleCountry();
+ $obj->hydrate($row);
+ TaxRuleCountryPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return TaxRuleCountry|TaxRuleCountry[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|TaxRuleCountry[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234
+ * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34)
+ * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
+ *
+ *
+ * @see filterByTaxRule()
+ *
+ * @param mixed $taxRuleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleId($taxRuleId = null, $comparison = null)
+ {
+ if (is_array($taxRuleId)) {
+ $useMinMax = false;
+ if (isset($taxRuleId['min'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxRuleId['max'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRuleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @see filterByCountry()
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxId(1234); // WHERE tax_id = 1234
+ * $query->filterByTaxId(array(12, 34)); // WHERE tax_id IN (12, 34)
+ * $query->filterByTaxId(array('min' => 12)); // WHERE tax_id > 12
+ *
+ *
+ * @see filterByTax()
+ *
+ * @param mixed $taxId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByTaxId($taxId = null, $comparison = null)
+ {
+ if (is_array($taxId)) {
+ $useMinMax = false;
+ if (isset($taxId['min'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $taxId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxId['max'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $taxId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $taxId, $comparison);
+ }
+
+ /**
+ * Filter the query on the none column
+ *
+ * Example usage:
+ *
+ * $query->filterByNone(1234); // WHERE none = 1234
+ * $query->filterByNone(array(12, 34)); // WHERE none IN (12, 34)
+ * $query->filterByNone(array('min' => 12)); // WHERE none > 12
+ *
+ *
+ * @param mixed $none The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByNone($none = null, $comparison = null)
+ {
+ if (is_array($none)) {
+ $useMinMax = false;
+ if (isset($none['min'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::NONE, $none['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($none['max'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::NONE, $none['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::NONE, $none, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related Tax object
+ *
+ * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTax($tax, $comparison = null)
+ {
+ if ($tax instanceof Tax) {
+ return $this
+ ->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $tax->getId(), $comparison);
+ } elseif ($tax instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Tax 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 joinTax($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Tax');
+
+ // 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, 'Tax');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Tax relation Tax 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\TaxQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTax($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Tax', '\Thelia\Model\TaxQuery');
+ }
+
+ /**
+ * Filter the query by a related TaxRule object
+ *
+ * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTaxRule($taxRule, $comparison = null)
+ {
+ if ($taxRule instanceof TaxRule) {
+ return $this
+ ->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRule->getId(), $comparison);
+ } elseif ($taxRule instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxRuleCountryPeer::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 TaxRuleCountryQuery 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 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
+ *
+ * @param TaxRuleCountry $taxRuleCountry Object to remove from the list of results
+ *
+ * @return TaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function prune($taxRuleCountry = null)
+ {
+ if ($taxRuleCountry) {
+ $this->addUsingAlias(TaxRuleCountryPeer::ID, $taxRuleCountry->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php b/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php
new file mode 100644
index 000000000..fde9bb97b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php
@@ -0,0 +1,1265 @@
+id;
+ }
+
+ /**
+ * Get the [tax_rule_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxRuleId()
+ {
+ return $this->tax_rule_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->created_at === null) {
+ return null;
+ }
+
+ if ($this->created_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->updated_at === null) {
+ return null;
+ }
+
+ if ($this->updated_at === '0000-00-00 00:00:00') {
+ // while technically this is not a default value of null,
+ // this seems to be closest in meaning.
+ return null;
+ } else {
+ try {
+ $dt = new DateTime($this->updated_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return TaxRuleDesc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxRuleDescPeer::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [tax_rule_id] column.
+ *
+ * @param int $v new value
+ * @return TaxRuleDesc The current object (for fluent API support)
+ */
+ public function setTaxRuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_rule_id !== $v) {
+ $this->tax_rule_id = $v;
+ $this->modifiedColumns[] = TaxRuleDescPeer::TAX_RULE_ID;
+ }
+
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
+
+ return $this;
+ } // setTaxRuleId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return TaxRuleDesc The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = TaxRuleDescPeer::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return TaxRuleDesc The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = TaxRuleDescPeer::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return TaxRuleDesc The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = TaxRuleDescPeer::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return TaxRuleDesc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->created_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxRuleDescPeer::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return TaxRuleDesc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->updated_at = $newDateAsString;
+ $this->modifiedColumns[] = TaxRuleDescPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->tax_rule_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = TaxRuleDescPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating TaxRuleDesc object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = TaxRuleDescPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aTaxRule = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = TaxRuleDescQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxRuleDescPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ 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()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = TaxRuleDescPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxRuleDescPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxRuleDescPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(TaxRuleDescPeer::TAX_RULE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`';
+ }
+ if ($this->isColumnModified(TaxRuleDescPeer::LANG)) {
+ $modifiedColumns[':p' . $index++] = '`LANG`';
+ }
+ if ($this->isColumnModified(TaxRuleDescPeer::TITLE)) {
+ $modifiedColumns[':p' . $index++] = '`TITLE`';
+ }
+ if ($this->isColumnModified(TaxRuleDescPeer::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
+ }
+ if ($this->isColumnModified(TaxRuleDescPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(TaxRuleDescPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `tax_rule_desc` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`TAX_RULE_ID`':
+ $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
+ break;
+ case '`LANG`':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case '`TITLE`':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case '`DESCRIPTION`':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ } else {
+ $this->validationFailures = $res;
+
+ return false;
+ }
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggreagated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $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);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getId();
+ break;
+ case 1:
+ return $this->getTaxRuleId();
+ break;
+ case 2:
+ return $this->getLang();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['TaxRuleDesc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['TaxRuleDesc'][$this->getPrimaryKey()] = true;
+ $keys = TaxRuleDescPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTaxRuleId(),
+ $keys[2] => $this->getLang(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ if ($includeForeignObjects) {
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleDescPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setId($value);
+ break;
+ case 1:
+ $this->setTaxRuleId($value);
+ break;
+ case 2:
+ $this->setLang($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = TaxRuleDescPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLang($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(TaxRuleDescPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxRuleDescPeer::ID)) $criteria->add(TaxRuleDescPeer::ID, $this->id);
+ if ($this->isColumnModified(TaxRuleDescPeer::TAX_RULE_ID)) $criteria->add(TaxRuleDescPeer::TAX_RULE_ID, $this->tax_rule_id);
+ if ($this->isColumnModified(TaxRuleDescPeer::LANG)) $criteria->add(TaxRuleDescPeer::LANG, $this->lang);
+ if ($this->isColumnModified(TaxRuleDescPeer::TITLE)) $criteria->add(TaxRuleDescPeer::TITLE, $this->title);
+ if ($this->isColumnModified(TaxRuleDescPeer::DESCRIPTION)) $criteria->add(TaxRuleDescPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(TaxRuleDescPeer::CREATED_AT)) $criteria->add(TaxRuleDescPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(TaxRuleDescPeer::UPDATED_AT)) $criteria->add(TaxRuleDescPeer::UPDATED_AT, $this->updated_at);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(TaxRuleDescPeer::DATABASE_NAME);
+ $criteria->add(TaxRuleDescPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of TaxRuleDesc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTaxRuleId($this->getTaxRuleId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return TaxRuleDesc Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return TaxRuleDescPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new TaxRuleDescPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a TaxRule object.
+ *
+ * @param TaxRule $v
+ * @return TaxRuleDesc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTaxRule(TaxRule $v = null)
+ {
+ 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
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->tax_rule_id = null;
+ $this->lang = null;
+ $this->title = null;
+ $this->description = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volumne/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aTaxRule = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxRuleDescPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleDescPeer.php b/core/lib/Thelia/Model/om/BaseTaxRuleDescPeer.php
new file mode 100644
index 000000000..6b7ff375d
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleDescPeer.php
@@ -0,0 +1,1032 @@
+ array ('Id', 'TaxRuleId', 'Lang', 'Title', 'Description', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'lang', 'title', 'description', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (TaxRuleDescPeer::ID, TaxRuleDescPeer::TAX_RULE_ID, TaxRuleDescPeer::LANG, TaxRuleDescPeer::TITLE, TaxRuleDescPeer::DESCRIPTION, TaxRuleDescPeer::CREATED_AT, TaxRuleDescPeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'lang', 'title', 'description', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. TaxRuleDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ BasePeer::TYPE_COLNAME => array (TaxRuleDescPeer::ID => 0, TaxRuleDescPeer::TAX_RULE_ID => 1, TaxRuleDescPeer::LANG => 2, TaxRuleDescPeer::TITLE => 3, TaxRuleDescPeer::DESCRIPTION => 4, TaxRuleDescPeer::CREATED_AT => 5, TaxRuleDescPeer::UPDATED_AT => 6, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = TaxRuleDescPeer::getFieldNames($toType);
+ $key = isset(TaxRuleDescPeer::$fieldKeys[$fromType][$name]) ? TaxRuleDescPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(TaxRuleDescPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, TaxRuleDescPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return TaxRuleDescPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. TaxRuleDescPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(TaxRuleDescPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxRuleDescPeer::ID);
+ $criteria->addSelectColumn(TaxRuleDescPeer::TAX_RULE_ID);
+ $criteria->addSelectColumn(TaxRuleDescPeer::LANG);
+ $criteria->addSelectColumn(TaxRuleDescPeer::TITLE);
+ $criteria->addSelectColumn(TaxRuleDescPeer::DESCRIPTION);
+ $criteria->addSelectColumn(TaxRuleDescPeer::CREATED_AT);
+ $criteria->addSelectColumn(TaxRuleDescPeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return TaxRuleDesc
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = TaxRuleDescPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return TaxRuleDescPeer::populateObjects(TaxRuleDescPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ TaxRuleDescPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param TaxRuleDesc $obj A TaxRuleDesc object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ TaxRuleDescPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A TaxRuleDesc object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof TaxRuleDesc) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or TaxRuleDesc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(TaxRuleDescPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return TaxRuleDesc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(TaxRuleDescPeer::$instances[$key])) {
+ return TaxRuleDescPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ TaxRuleDescPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to tax_rule_desc
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = TaxRuleDescPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = TaxRuleDescPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = TaxRuleDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxRuleDescPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (TaxRuleDesc object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = TaxRuleDescPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = TaxRuleDescPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + TaxRuleDescPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxRuleDescPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ TaxRuleDescPeer::addInstanceToPool($obj, $key);
+ }
+
+ 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.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(TaxRuleDescPeer::DATABASE_NAME)->getTable(TaxRuleDescPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseTaxRuleDescPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseTaxRuleDescPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxRuleDescTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return TaxRuleDescPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a TaxRuleDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or TaxRuleDesc object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from TaxRuleDesc object
+ }
+
+ if ($criteria->containsKey(TaxRuleDescPeer::ID) && $criteria->keyContainsValue(TaxRuleDescPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxRuleDescPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a TaxRuleDesc or Criteria object.
+ *
+ * @param mixed $values Criteria or TaxRuleDesc object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(TaxRuleDescPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(TaxRuleDescPeer::ID);
+ $value = $criteria->remove(TaxRuleDescPeer::ID);
+ if ($value) {
+ $selectCriteria->add(TaxRuleDescPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(TaxRuleDescPeer::TABLE_NAME);
+ }
+
+ } else { // $values is TaxRuleDesc object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the tax_rule_desc table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $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
+ // instances get re-added by the select statement contained therein).
+ TaxRuleDescPeer::clearInstancePool();
+ TaxRuleDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a TaxRuleDesc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or TaxRuleDesc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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
+ $criteria->setDbName(TaxRuleDescPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ TaxRuleDescPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given TaxRuleDesc object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param TaxRuleDesc $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(TaxRuleDescPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(TaxRuleDescPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(TaxRuleDescPeer::DATABASE_NAME, TaxRuleDescPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return TaxRuleDesc
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = TaxRuleDescPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(TaxRuleDescPeer::DATABASE_NAME);
+ $criteria->add(TaxRuleDescPeer::ID, $pk);
+
+ $v = TaxRuleDescPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return TaxRuleDesc[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(TaxRuleDescPeer::DATABASE_NAME);
+ $criteria->add(TaxRuleDescPeer::ID, $pks, Criteria::IN);
+ $objs = TaxRuleDescPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseTaxRuleDescPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseTaxRuleDescPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php
new file mode 100644
index 000000000..98f7d5d13
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php
@@ -0,0 +1,580 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return TaxRuleDesc|TaxRuleDesc[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxRuleDescPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRuleDescPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return TaxRuleDesc A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `TAX_RULE_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CREATED_AT`, `UPDATED_AT` FROM `tax_rule_desc` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new TaxRuleDesc();
+ $obj->hydrate($row);
+ TaxRuleDescPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return TaxRuleDesc|TaxRuleDesc[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|TaxRuleDesc[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(TaxRuleDescPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(TaxRuleDescPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(TaxRuleDescPeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234
+ * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34)
+ * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
+ *
+ *
+ * @see filterByTaxRule()
+ *
+ * @param mixed $taxRuleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleId($taxRuleId = null, $comparison = null)
+ {
+ if (is_array($taxRuleId)) {
+ $useMinMax = false;
+ if (isset($taxRuleId['min'])) {
+ $this->addUsingAlias(TaxRuleDescPeer::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxRuleId['max'])) {
+ $this->addUsingAlias(TaxRuleDescPeer::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleDescPeer::TAX_RULE_ID, $taxRuleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleDescPeer::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleDescPeer::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleDescPeer::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(TaxRuleDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(TaxRuleDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleDescPeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(TaxRuleDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(TaxRuleDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleDescPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related TaxRule object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTaxRule($taxRule, $comparison = null)
+ {
+ if ($taxRule instanceof TaxRule) {
+ return $this
+ ->addUsingAlias(TaxRuleDescPeer::TAX_RULE_ID, $taxRule->getId(), $comparison);
+ } elseif ($taxRule instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxRuleDescPeer::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 TaxRuleDescQuery 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');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param TaxRuleDesc $taxRuleDesc Object to remove from the list of results
+ *
+ * @return TaxRuleDescQuery The current query, for fluid interface
+ */
+ public function prune($taxRuleDesc = null)
+ {
+ if ($taxRuleDesc) {
+ $this->addUsingAlias(TaxRuleDescPeer::ID, $taxRuleDesc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php
new file mode 100644
index 000000000..1b038414b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php
@@ -0,0 +1,790 @@
+ array ('Id', 'Code', 'CreatedAt', 'UpdatedAt', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'createdAt', 'updatedAt', ),
+ BasePeer::TYPE_COLNAME => array (TaxRulePeer::ID, TaxRulePeer::CODE, TaxRulePeer::CREATED_AT, TaxRulePeer::UPDATED_AT, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'created_at', 'updated_at', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. TaxRulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ BasePeer::TYPE_COLNAME => array (TaxRulePeer::ID => 0, TaxRulePeer::CODE => 1, TaxRulePeer::CREATED_AT => 2, TaxRulePeer::UPDATED_AT => 3, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = TaxRulePeer::getFieldNames($toType);
+ $key = isset(TaxRulePeer::$fieldKeys[$fromType][$name]) ? TaxRulePeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(TaxRulePeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, TaxRulePeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return TaxRulePeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. TaxRulePeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(TaxRulePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxRulePeer::ID);
+ $criteria->addSelectColumn(TaxRulePeer::CODE);
+ $criteria->addSelectColumn(TaxRulePeer::CREATED_AT);
+ $criteria->addSelectColumn(TaxRulePeer::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there 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
+ $criteria->setDbName(TaxRulePeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->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 one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return TaxRule
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = TaxRulePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return TaxRulePeer::populateObjects(TaxRulePeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement durirectly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ TaxRulePeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param TaxRule $obj A TaxRule object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getId();
+ } // if key === null
+ TaxRulePeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A TaxRule object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof TaxRule) {
+ $key = (string) $value->getId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or TaxRule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(TaxRulePeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return TaxRule Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(TaxRulePeer::$instances[$key])) {
+ return TaxRulePeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ TaxRulePeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to tax_rule
+ * by a foreign key with ON DELETE CASCADE
+ */
+ 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();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = TaxRulePeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = TaxRulePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxRulePeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (TaxRule object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = TaxRulePeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + TaxRulePeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxRulePeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ TaxRulePeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(TaxRulePeer::DATABASE_NAME)->getTable(TaxRulePeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseTaxRulePeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseTaxRulePeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxRuleTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return TaxRulePeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a TaxRule or Criteria object.
+ *
+ * @param mixed $values Criteria or TaxRule object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from TaxRule object
+ }
+
+ if ($criteria->containsKey(TaxRulePeer::ID) && $criteria->keyContainsValue(TaxRulePeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxRulePeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a TaxRule or Criteria object.
+ *
+ * @param mixed $values Criteria or TaxRule object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(TaxRulePeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(TaxRulePeer::ID);
+ $value = $criteria->remove(TaxRulePeer::ID);
+ if ($value) {
+ $selectCriteria->add(TaxRulePeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME);
+ }
+
+ } else { // $values is TaxRule object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the tax_rule table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(TaxRulePeer::TABLE_NAME, $con, TaxRulePeer::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
+ // instances get re-added by the select statement contained therein).
+ TaxRulePeer::clearInstancePool();
+ TaxRulePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a TaxRule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or TaxRule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ 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.
+ TaxRulePeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof TaxRule) { // it's a model object
+ // invalidate the cache for this single object
+ TaxRulePeer::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(TaxRulePeer::DATABASE_NAME);
+ $criteria->add(TaxRulePeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ TaxRulePeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRulePeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ TaxRulePeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given TaxRule object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param TaxRule $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(TaxRulePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(TaxRulePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(TaxRulePeer::DATABASE_NAME, TaxRulePeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return TaxRule
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = TaxRulePeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(TaxRulePeer::DATABASE_NAME);
+ $criteria->add(TaxRulePeer::ID, $pk);
+
+ $v = TaxRulePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return TaxRule[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(TaxRulePeer::DATABASE_NAME);
+ $criteria->add(TaxRulePeer::ID, $pks, Criteria::IN);
+ $objs = TaxRulePeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseTaxRulePeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseTaxRulePeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php
new file mode 100644
index 000000000..0a96357bf
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php
@@ -0,0 +1,623 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return TaxRule|TaxRule[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxRulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is alredy in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return TaxRule A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CODE`, `CREATED_AT`, `UPDATED_AT` FROM `tax_rule` WHERE `ID` = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new TaxRule();
+ $obj->hydrate($row);
+ TaxRulePeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return TaxRule|TaxRule[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|TaxRule[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(TaxRulePeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(TaxRulePeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(TaxRulePeer::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRulePeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * 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 TaxRuleQuery 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(TaxRulePeer::ID, $product->getTaxRuleId(), $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 TaxRuleQuery 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 TaxRuleCountry object
+ *
+ * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null)
+ {
+ if ($taxRuleCountry instanceof TaxRuleCountry) {
+ return $this
+ ->addUsingAlias(TaxRulePeer::ID, $taxRuleCountry->getTaxRuleId(), $comparison);
+ } elseif ($taxRuleCountry instanceof PropelObjectCollection) {
+ return $this
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRuleCountry relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRuleCountry');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRuleCountry');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRuleCountry relation TaxRuleCountry object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRuleCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery');
+ }
+
+ /**
+ * Filter the query by a related TaxRuleDesc object
+ *
+ * @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
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByTaxRuleDesc($taxRuleDesc, $comparison = null)
+ {
+ if ($taxRuleDesc instanceof TaxRuleDesc) {
+ return $this
+ ->addUsingAlias(TaxRulePeer::ID, $taxRuleDesc->getTaxRuleId(), $comparison);
+ } elseif ($taxRuleDesc instanceof PropelObjectCollection) {
+ return $this
+ ->useTaxRuleDescQuery()
+ ->filterByPrimaryKeys($taxRuleDesc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxRuleDesc() only accepts arguments of type TaxRuleDesc or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRuleDesc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function joinTaxRuleDesc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRuleDesc');
+
+ // 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, 'TaxRuleDesc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRuleDesc relation TaxRuleDesc 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\TaxRuleDescQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleDescQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRuleDesc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleDesc', '\Thelia\Model\TaxRuleDescQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param TaxRule $taxRule Object to remove from the list of results
+ *
+ * @return TaxRuleQuery The current query, for fluid interface
+ */
+ public function prune($taxRule = null)
+ {
+ if ($taxRule) {
+ $this->addUsingAlias(TaxRulePeer::ID, $taxRule->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/local/config/.htaccess b/local/config/.htaccess
new file mode 100644
index 000000000..f239fe831
--- /dev/null
+++ b/local/config/.htaccess
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all
\ No newline at end of file