diff --git a/core/lib/Thelia/Model/CategoryVersion.php b/core/lib/Thelia/Model/CategoryVersion.php
new file mode 100644
index 000000000..39e912def
--- /dev/null
+++ b/core/lib/Thelia/Model/CategoryVersion.php
@@ -0,0 +1,21 @@
+addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
// validators
} // initialize()
@@ -65,6 +68,7 @@ class CategoryTableMap extends TableMap
$this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Documents');
$this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
$this->addRelation('CategoryI18n', 'Thelia\\Model\\CategoryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryI18ns');
+ $this->addRelation('CategoryVersion', 'Thelia\\Model\\CategoryVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryVersions');
} // buildRelations()
/**
@@ -78,6 +82,7 @@ class CategoryTableMap extends TableMap
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ),
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
);
} // getBehaviors()
diff --git a/core/lib/Thelia/Model/map/CategoryVersionTableMap.php b/core/lib/Thelia/Model/map/CategoryVersionTableMap.php
new file mode 100644
index 000000000..64d7f7268
--- /dev/null
+++ b/core/lib/Thelia/Model/map/CategoryVersionTableMap.php
@@ -0,0 +1,66 @@
+setName('category_version');
+ $this->setPhpName('CategoryVersion');
+ $this->setClassname('Thelia\\Model\\CategoryVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
+ $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // CategoryVersionTableMap
diff --git a/core/lib/Thelia/Model/map/ContentTableMap.php b/core/lib/Thelia/Model/map/ContentTableMap.php
index 179987efd..68f66d2f4 100644
--- a/core/lib/Thelia/Model/map/ContentTableMap.php
+++ b/core/lib/Thelia/Model/map/ContentTableMap.php
@@ -47,6 +47,9 @@ class ContentTableMap extends TableMap
$this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
// validators
} // initialize()
@@ -61,6 +64,7 @@ class ContentTableMap extends TableMap
$this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
$this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders');
$this->addRelation('ContentI18n', 'Thelia\\Model\\ContentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentI18ns');
+ $this->addRelation('ContentVersion', 'Thelia\\Model\\ContentVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentVersions');
} // buildRelations()
/**
@@ -74,6 +78,7 @@ class ContentTableMap extends TableMap
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ),
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
);
} // getBehaviors()
diff --git a/core/lib/Thelia/Model/map/ContentVersionTableMap.php b/core/lib/Thelia/Model/map/ContentVersionTableMap.php
new file mode 100644
index 000000000..16852708d
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ContentVersionTableMap.php
@@ -0,0 +1,64 @@
+setName('content_version');
+ $this->setPhpName('ContentVersion');
+ $this->setClassname('Thelia\\Model\\ContentVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // ContentVersionTableMap
diff --git a/core/lib/Thelia/Model/map/FolderTableMap.php b/core/lib/Thelia/Model/map/FolderTableMap.php
index eb45af179..e4319f402 100644
--- a/core/lib/Thelia/Model/map/FolderTableMap.php
+++ b/core/lib/Thelia/Model/map/FolderTableMap.php
@@ -49,6 +49,9 @@ class FolderTableMap extends TableMap
$this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
// validators
} // initialize()
@@ -62,6 +65,7 @@ class FolderTableMap extends TableMap
$this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
$this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders');
$this->addRelation('FolderI18n', 'Thelia\\Model\\FolderI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FolderI18ns');
+ $this->addRelation('FolderVersion', 'Thelia\\Model\\FolderVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FolderVersions');
} // buildRelations()
/**
@@ -75,6 +79,7 @@ class FolderTableMap extends TableMap
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ),
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
);
} // getBehaviors()
diff --git a/core/lib/Thelia/Model/map/FolderVersionTableMap.php b/core/lib/Thelia/Model/map/FolderVersionTableMap.php
new file mode 100644
index 000000000..7a6fe942b
--- /dev/null
+++ b/core/lib/Thelia/Model/map/FolderVersionTableMap.php
@@ -0,0 +1,66 @@
+setName('folder_version');
+ $this->setPhpName('FolderVersion');
+ $this->setClassname('Thelia\\Model\\FolderVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null);
+ $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // FolderVersionTableMap
diff --git a/core/lib/Thelia/Model/map/MessageTableMap.php b/core/lib/Thelia/Model/map/MessageTableMap.php
index 5ab6231c7..c20ea6704 100644
--- a/core/lib/Thelia/Model/map/MessageTableMap.php
+++ b/core/lib/Thelia/Model/map/MessageTableMap.php
@@ -48,6 +48,9 @@ class MessageTableMap extends TableMap
$this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
// validators
} // initialize()
@@ -57,6 +60,7 @@ class MessageTableMap extends TableMap
public function buildRelations()
{
$this->addRelation('MessageI18n', 'Thelia\\Model\\MessageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'MessageI18ns');
+ $this->addRelation('MessageVersion', 'Thelia\\Model\\MessageVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'MessageVersions');
} // buildRelations()
/**
@@ -70,6 +74,7 @@ class MessageTableMap extends TableMap
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ),
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, description_html', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
);
} // getBehaviors()
diff --git a/core/lib/Thelia/Model/map/MessageVersionTableMap.php b/core/lib/Thelia/Model/map/MessageVersionTableMap.php
new file mode 100644
index 000000000..3cc7e00e1
--- /dev/null
+++ b/core/lib/Thelia/Model/map/MessageVersionTableMap.php
@@ -0,0 +1,65 @@
+setName('message_version');
+ $this->setPhpName('MessageVersion');
+ $this->setClassname('Thelia\\Model\\MessageVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
+ $this->addColumn('SECURED', 'Secured', 'TINYINT', false, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Message', 'Thelia\\Model\\Message', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // MessageVersionTableMap
diff --git a/core/lib/Thelia/Model/map/ProductTableMap.php b/core/lib/Thelia/Model/map/ProductTableMap.php
index 978face1f..926c23e91 100644
--- a/core/lib/Thelia/Model/map/ProductTableMap.php
+++ b/core/lib/Thelia/Model/map/ProductTableMap.php
@@ -56,6 +56,9 @@ class ProductTableMap extends TableMap
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
// validators
} // initialize()
@@ -75,6 +78,7 @@ class ProductTableMap extends TableMap
$this->addRelation('AccessoryRelatedByAccessory', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessorysRelatedByAccessory');
$this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
$this->addRelation('ProductI18n', 'Thelia\\Model\\ProductI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductI18ns');
+ $this->addRelation('ProductVersion', 'Thelia\\Model\\ProductVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductVersions');
} // buildRelations()
/**
@@ -88,6 +92,7 @@ class ProductTableMap extends TableMap
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ),
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
);
} // getBehaviors()
diff --git a/core/lib/Thelia/Model/map/ProductVersionTableMap.php b/core/lib/Thelia/Model/map/ProductVersionTableMap.php
new file mode 100644
index 000000000..3267ac2d4
--- /dev/null
+++ b/core/lib/Thelia/Model/map/ProductVersionTableMap.php
@@ -0,0 +1,73 @@
+setName('product_version');
+ $this->setPhpName('ProductVersion');
+ $this->setClassname('Thelia\\Model\\ProductVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null);
+ $this->addColumn('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', false, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null);
+ $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
+ $this->addColumn('PRICE2', 'Price2', 'FLOAT', false, null, null);
+ $this->addColumn('ECOTAX', 'Ecotax', 'FLOAT', false, null, null);
+ $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0);
+ $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0);
+ $this->addColumn('STOCK', 'Stock', 'INTEGER', false, null, 0);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0);
+ $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // ProductVersionTableMap
diff --git a/core/lib/Thelia/Model/om/BaseCategory.php b/core/lib/Thelia/Model/om/BaseCategory.php
index 8c71be9a5..ea819a426 100644
--- a/core/lib/Thelia/Model/om/BaseCategory.php
+++ b/core/lib/Thelia/Model/om/BaseCategory.php
@@ -22,6 +22,9 @@ use Thelia\Model\CategoryI18n;
use Thelia\Model\CategoryI18nQuery;
use Thelia\Model\CategoryPeer;
use Thelia\Model\CategoryQuery;
+use Thelia\Model\CategoryVersion;
+use Thelia\Model\CategoryVersionPeer;
+use Thelia\Model\CategoryVersionQuery;
use Thelia\Model\ContentAssoc;
use Thelia\Model\ContentAssocQuery;
use Thelia\Model\Document;
@@ -105,6 +108,25 @@ abstract class BaseCategory extends BaseObject implements Persistent
*/
protected $updated_at;
+ /**
+ * The value for the version field.
+ * Note: this column has a database default value of: 0
+ * @var int
+ */
+ protected $version;
+
+ /**
+ * The value for the version_created_at field.
+ * @var string
+ */
+ protected $version_created_at;
+
+ /**
+ * The value for the version_created_by field.
+ * @var string
+ */
+ protected $version_created_by;
+
/**
* @var PropelObjectCollection|ProductCategory[] Collection to store aggregation of ProductCategory objects.
*/
@@ -153,6 +175,12 @@ abstract class BaseCategory extends BaseObject implements Persistent
protected $collCategoryI18ns;
protected $collCategoryI18nsPartial;
+ /**
+ * @var PropelObjectCollection|CategoryVersion[] Collection to store aggregation of CategoryVersion objects.
+ */
+ protected $collCategoryVersions;
+ protected $collCategoryVersionsPartial;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -181,6 +209,14 @@ abstract class BaseCategory extends BaseObject implements Persistent
*/
protected $currentTranslations;
+ // versionable behavior
+
+
+ /**
+ * @var bool
+ */
+ protected $enforceVersion = false;
+
/**
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
@@ -229,6 +265,33 @@ abstract class BaseCategory extends BaseObject implements Persistent
*/
protected $categoryI18nsScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $categoryVersionsScheduledForDeletion = null;
+
+ /**
+ * Applies default values to this object.
+ * This method should be called from the object's constructor (or
+ * equivalent initialization method).
+ * @see __construct()
+ */
+ public function applyDefaultValues()
+ {
+ $this->version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseCategory object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
/**
* Get the [id] column value.
*
@@ -353,6 +416,63 @@ abstract class BaseCategory extends BaseObject implements Persistent
}
}
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
/**
* Set the value of [id] column.
*
@@ -504,6 +624,71 @@ abstract class BaseCategory extends BaseObject implements Persistent
return $this;
} // setUpdatedAt()
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return Category The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = CategoryPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = CategoryPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return Category The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = CategoryPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -514,6 +699,10 @@ abstract class BaseCategory extends BaseObject implements Persistent
*/
public function hasOnlyDefaultValues()
{
+ if ($this->version !== 0) {
+ return false;
+ }
+
// otherwise, everything was equal, so return true
return true;
} // hasOnlyDefaultValues()
@@ -543,6 +732,9 @@ abstract class BaseCategory extends BaseObject implements Persistent
$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->version = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
+ $this->version_created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->version_created_by = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
$this->resetModified();
$this->setNew(false);
@@ -551,7 +743,7 @@ abstract class BaseCategory extends BaseObject implements Persistent
$this->ensureConsistency();
}
- return $startcol + 7; // 7 = CategoryPeer::NUM_HYDRATE_COLUMNS.
+ return $startcol + 10; // 10 = CategoryPeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Category object", $e);
@@ -629,6 +821,8 @@ abstract class BaseCategory extends BaseObject implements Persistent
$this->collCategoryI18ns = null;
+ $this->collCategoryVersions = null;
+
} // if (deep)
}
@@ -699,6 +893,14 @@ abstract class BaseCategory extends BaseObject implements Persistent
$isInsert = $this->isNew();
try {
$ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
if ($isInsert) {
$ret = $ret && $this->preInsert($con);
// timestampable behavior
@@ -723,6 +925,10 @@ abstract class BaseCategory extends BaseObject implements Persistent
$this->postUpdate($con);
}
$this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
CategoryPeer::addInstanceToPool($this);
} else {
$affectedRows = 0;
@@ -904,6 +1110,23 @@ abstract class BaseCategory extends BaseObject implements Persistent
}
}
+ if ($this->categoryVersionsScheduledForDeletion !== null) {
+ if (!$this->categoryVersionsScheduledForDeletion->isEmpty()) {
+ CategoryVersionQuery::create()
+ ->filterByPrimaryKeys($this->categoryVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->categoryVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCategoryVersions !== null) {
+ foreach ($this->collCategoryVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -951,6 +1174,15 @@ abstract class BaseCategory extends BaseObject implements Persistent
if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
}
+ if ($this->isColumnModified(CategoryPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
$sql = sprintf(
'INSERT INTO `category` (%s) VALUES (%s)',
@@ -983,6 +1215,15 @@ abstract class BaseCategory extends BaseObject implements Persistent
case '`UPDATED_AT`':
$stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
break;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
}
}
$stmt->execute();
@@ -1146,6 +1387,14 @@ abstract class BaseCategory extends BaseObject implements Persistent
}
}
+ if ($this->collCategoryVersions !== null) {
+ foreach ($this->collCategoryVersions as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1202,6 +1451,15 @@ abstract class BaseCategory extends BaseObject implements Persistent
case 6:
return $this->getUpdatedAt();
break;
+ case 7:
+ return $this->getVersion();
+ break;
+ case 8:
+ return $this->getVersionCreatedAt();
+ break;
+ case 9:
+ return $this->getVersionCreatedBy();
+ break;
default:
return null;
break;
@@ -1238,6 +1496,9 @@ abstract class BaseCategory extends BaseObject implements Persistent
$keys[4] => $this->getPosition(),
$keys[5] => $this->getCreatedAt(),
$keys[6] => $this->getUpdatedAt(),
+ $keys[7] => $this->getVersion(),
+ $keys[8] => $this->getVersionCreatedAt(),
+ $keys[9] => $this->getVersionCreatedBy(),
);
if ($includeForeignObjects) {
if (null !== $this->collProductCategorys) {
@@ -1264,6 +1525,9 @@ abstract class BaseCategory extends BaseObject implements Persistent
if (null !== $this->collCategoryI18ns) {
$result['CategoryI18ns'] = $this->collCategoryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
+ if (null !== $this->collCategoryVersions) {
+ $result['CategoryVersions'] = $this->collCategoryVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
}
return $result;
@@ -1319,6 +1583,15 @@ abstract class BaseCategory extends BaseObject implements Persistent
case 6:
$this->setUpdatedAt($value);
break;
+ case 7:
+ $this->setVersion($value);
+ break;
+ case 8:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 9:
+ $this->setVersionCreatedBy($value);
+ break;
} // switch()
}
@@ -1350,6 +1623,9 @@ abstract class BaseCategory extends BaseObject implements Persistent
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]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
}
/**
@@ -1368,6 +1644,9 @@ abstract class BaseCategory extends BaseObject implements Persistent
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);
+ if ($this->isColumnModified(CategoryPeer::VERSION)) $criteria->add(CategoryPeer::VERSION, $this->version);
+ if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) $criteria->add(CategoryPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_BY)) $criteria->add(CategoryPeer::VERSION_CREATED_BY, $this->version_created_by);
return $criteria;
}
@@ -1437,6 +1716,9 @@ abstract class BaseCategory extends BaseObject implements Persistent
$copyObj->setPosition($this->getPosition());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@@ -1493,6 +1775,12 @@ abstract class BaseCategory extends BaseObject implements Persistent
}
}
+ foreach ($this->getCategoryVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCategoryVersion($relObj->copy($deepCopy));
+ }
+ }
+
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1578,6 +1866,9 @@ abstract class BaseCategory extends BaseObject implements Persistent
if ('CategoryI18n' == $relationName) {
$this->initCategoryI18ns();
}
+ if ('CategoryVersion' == $relationName) {
+ $this->initCategoryVersions();
+ }
}
/**
@@ -3590,6 +3881,213 @@ abstract class BaseCategory extends BaseObject implements Persistent
}
}
+ /**
+ * Clears out the collCategoryVersions 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 addCategoryVersions()
+ */
+ public function clearCategoryVersions()
+ {
+ $this->collCategoryVersions = null; // important to set this to null since that means it is uninitialized
+ $this->collCategoryVersionsPartial = null;
+ }
+
+ /**
+ * reset is the collCategoryVersions collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialCategoryVersions($v = true)
+ {
+ $this->collCategoryVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCategoryVersions collection.
+ *
+ * By default this just sets the collCategoryVersions collection to an empty array (like clearcollCategoryVersions());
+ * 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 initCategoryVersions($overrideExisting = true)
+ {
+ if (null !== $this->collCategoryVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collCategoryVersions = new PropelObjectCollection();
+ $this->collCategoryVersions->setModel('CategoryVersion');
+ }
+
+ /**
+ * Gets an array of CategoryVersion 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|CategoryVersion[] List of CategoryVersion objects
+ * @throws PropelException
+ */
+ public function getCategoryVersions($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collCategoryVersionsPartial && !$this->isNew();
+ if (null === $this->collCategoryVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCategoryVersions) {
+ // return empty collection
+ $this->initCategoryVersions();
+ } else {
+ $collCategoryVersions = CategoryVersionQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCategoryVersionsPartial && count($collCategoryVersions)) {
+ $this->initCategoryVersions(false);
+
+ foreach($collCategoryVersions as $obj) {
+ if (false == $this->collCategoryVersions->contains($obj)) {
+ $this->collCategoryVersions->append($obj);
+ }
+ }
+
+ $this->collCategoryVersionsPartial = true;
+ }
+
+ return $collCategoryVersions;
+ }
+
+ if($partial && $this->collCategoryVersions) {
+ foreach($this->collCategoryVersions as $obj) {
+ if($obj->isNew()) {
+ $collCategoryVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collCategoryVersions = $collCategoryVersions;
+ $this->collCategoryVersionsPartial = false;
+ }
+ }
+
+ return $this->collCategoryVersions;
+ }
+
+ /**
+ * Sets a collection of CategoryVersion 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 $categoryVersions A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setCategoryVersions(PropelCollection $categoryVersions, PropelPDO $con = null)
+ {
+ $this->categoryVersionsScheduledForDeletion = $this->getCategoryVersions(new Criteria(), $con)->diff($categoryVersions);
+
+ foreach ($this->categoryVersionsScheduledForDeletion as $categoryVersionRemoved) {
+ $categoryVersionRemoved->setCategory(null);
+ }
+
+ $this->collCategoryVersions = null;
+ foreach ($categoryVersions as $categoryVersion) {
+ $this->addCategoryVersion($categoryVersion);
+ }
+
+ $this->collCategoryVersions = $categoryVersions;
+ $this->collCategoryVersionsPartial = false;
+ }
+
+ /**
+ * Returns the number of related CategoryVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CategoryVersion objects.
+ * @throws PropelException
+ */
+ public function countCategoryVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCategoryVersionsPartial && !$this->isNew();
+ if (null === $this->collCategoryVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCategoryVersions) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getCategoryVersions());
+ }
+ $query = CategoryVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCategoryVersions);
+ }
+ }
+
+ /**
+ * Method called to associate a CategoryVersion object to this object
+ * through the CategoryVersion foreign key attribute.
+ *
+ * @param CategoryVersion $l CategoryVersion
+ * @return Category The current object (for fluent API support)
+ */
+ public function addCategoryVersion(CategoryVersion $l)
+ {
+ if ($this->collCategoryVersions === null) {
+ $this->initCategoryVersions();
+ $this->collCategoryVersionsPartial = true;
+ }
+ if (!$this->collCategoryVersions->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddCategoryVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CategoryVersion $categoryVersion The categoryVersion object to add.
+ */
+ protected function doAddCategoryVersion($categoryVersion)
+ {
+ $this->collCategoryVersions[]= $categoryVersion;
+ $categoryVersion->setCategory($this);
+ }
+
+ /**
+ * @param CategoryVersion $categoryVersion The categoryVersion object to remove.
+ */
+ public function removeCategoryVersion($categoryVersion)
+ {
+ if ($this->getCategoryVersions()->contains($categoryVersion)) {
+ $this->collCategoryVersions->remove($this->collCategoryVersions->search($categoryVersion));
+ if (null === $this->categoryVersionsScheduledForDeletion) {
+ $this->categoryVersionsScheduledForDeletion = clone $this->collCategoryVersions;
+ $this->categoryVersionsScheduledForDeletion->clear();
+ }
+ $this->categoryVersionsScheduledForDeletion[]= $categoryVersion;
+ $categoryVersion->setCategory(null);
+ }
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -3602,9 +4100,13 @@ abstract class BaseCategory extends BaseObject implements Persistent
$this->position = null;
$this->created_at = null;
$this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
+ $this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
@@ -3662,6 +4164,11 @@ abstract class BaseCategory extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
+ if ($this->collCategoryVersions) {
+ foreach ($this->collCategoryVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
// i18n behavior
@@ -3700,6 +4207,10 @@ abstract class BaseCategory extends BaseObject implements Persistent
$this->collCategoryI18ns->clearIterator();
}
$this->collCategoryI18ns = null;
+ if ($this->collCategoryVersions instanceof PropelCollection) {
+ $this->collCategoryVersions->clearIterator();
+ }
+ $this->collCategoryVersions = null;
}
/**
@@ -3931,4 +4442,297 @@ abstract class BaseCategory extends BaseObject implements Persistent
return $this;
}
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return Category
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @param PropelPDO $con An optional PropelPDO connection to use.
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (CategoryPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return CategoryVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new CategoryVersion();
+ $version->setId($this->getId());
+ $version->setParent($this->getParent());
+ $version->setLink($this->getLink());
+ $version->setVisible($this->getVisible());
+ $version->setPosition($this->getPosition());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setCategory($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return Category The current object (for fluent API support)
+ * @throws PropelException - if no object with the given version can be found.
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No Category object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param CategoryVersion $version The version object to use
+ * @param PropelPDO $con the connection to use
+ * @param array $loadedObjects objects thats been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return Category The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+
+ $loadedObjects['Category'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setParent($version->getParent());
+ $this->setLink($version->getLink());
+ $this->setVisible($version->getVisible());
+ $this->setPosition($version->getPosition());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = CategoryVersionQuery::create()
+ ->filterByCategory($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return CategoryVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return CategoryVersionQuery::create()
+ ->filterByCategory($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return PropelObjectCollection A list of CategoryVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(CategoryVersionPeer::VERSION);
+
+ return $this->getCategoryVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($this->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param integer $number the number of record to return.
+ * @param CategoryVersionQuery|Criteria $criteria Additional criteria to filter.
+ * @param PropelPDO $con An optional connection to use.
+ *
+ * @return PropelCollection|CategoryVersion[] List of CategoryVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
+ {
+ $criteria = CategoryVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(CategoryVersionPeer::VERSION);
+ $criteria->limit($number);
+
+ return $this->getCategoryVersions($criteria, $con);
+ }
}
diff --git a/core/lib/Thelia/Model/om/BaseCategoryPeer.php b/core/lib/Thelia/Model/om/BaseCategoryPeer.php
index f5be9a382..7854dab58 100644
--- a/core/lib/Thelia/Model/om/BaseCategoryPeer.php
+++ b/core/lib/Thelia/Model/om/BaseCategoryPeer.php
@@ -13,6 +13,7 @@ use Thelia\Model\AttributeCategoryPeer;
use Thelia\Model\Category;
use Thelia\Model\CategoryI18nPeer;
use Thelia\Model\CategoryPeer;
+use Thelia\Model\CategoryVersionPeer;
use Thelia\Model\ContentAssocPeer;
use Thelia\Model\DocumentPeer;
use Thelia\Model\FeatureCategoryPeer;
@@ -44,13 +45,13 @@ abstract class BaseCategoryPeer
const TM_CLASS = 'CategoryTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 7;
+ const NUM_COLUMNS = 10;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
- const NUM_HYDRATE_COLUMNS = 7;
+ const NUM_HYDRATE_COLUMNS = 10;
/** the column name for the ID field */
const ID = 'category.ID';
@@ -73,6 +74,15 @@ abstract class BaseCategoryPeer
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'category.UPDATED_AT';
+ /** the column name for the VERSION field */
+ const VERSION = 'category.VERSION';
+
+ /** the column name for the VERSION_CREATED_AT field */
+ const VERSION_CREATED_AT = 'category.VERSION_CREATED_AT';
+
+ /** the column name for the VERSION_CREATED_BY field */
+ const VERSION_CREATED_BY = 'category.VERSION_CREATED_BY';
+
/** The default string format for model objects of the related table **/
const DEFAULT_STRING_FORMAT = 'YAML';
@@ -92,6 +102,13 @@ abstract class BaseCategoryPeer
* @var string
*/
const DEFAULT_LOCALE = 'en_EN';
+ // versionable behavior
+
+ /**
+ * Whether the versioning is enabled
+ */
+ static $isVersioningEnabled = true;
+
/**
* holds an array of fieldnames
*
@@ -99,12 +116,12 @@ abstract class BaseCategoryPeer
* e.g. CategoryPeer::$fieldNames[CategoryPeer::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => 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, )
+ BasePeer::TYPE_PHPNAME => array ('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (CategoryPeer::ID, CategoryPeer::PARENT, CategoryPeer::LINK, CategoryPeer::VISIBLE, CategoryPeer::POSITION, CategoryPeer::CREATED_AT, CategoryPeer::UPDATED_AT, CategoryPeer::VERSION, CategoryPeer::VERSION_CREATED_AT, CategoryPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@@ -114,12 +131,12 @@ abstract class BaseCategoryPeer
* 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, )
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
+ 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, CategoryPeer::VERSION => 7, CategoryPeer::VERSION_CREATED_AT => 8, CategoryPeer::VERSION_CREATED_BY => 9, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@@ -200,6 +217,9 @@ abstract class BaseCategoryPeer
$criteria->addSelectColumn(CategoryPeer::POSITION);
$criteria->addSelectColumn(CategoryPeer::CREATED_AT);
$criteria->addSelectColumn(CategoryPeer::UPDATED_AT);
+ $criteria->addSelectColumn(CategoryPeer::VERSION);
+ $criteria->addSelectColumn(CategoryPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(CategoryPeer::VERSION_CREATED_BY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.PARENT');
@@ -208,6 +228,9 @@ abstract class BaseCategoryPeer
$criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
}
}
@@ -431,6 +454,9 @@ abstract class BaseCategoryPeer
// Invalidate objects in CategoryI18nPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CategoryI18nPeer::clearInstancePool();
+ // Invalidate objects in CategoryVersionPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CategoryVersionPeer::clearInstancePool();
}
/**
@@ -824,6 +850,34 @@ abstract class BaseCategoryPeer
return $objs;
}
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ public static function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ public static function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ public static function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
} // BaseCategoryPeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
diff --git a/core/lib/Thelia/Model/om/BaseCategoryQuery.php b/core/lib/Thelia/Model/om/BaseCategoryQuery.php
index c1f2703b1..3b38ee90b 100644
--- a/core/lib/Thelia/Model/om/BaseCategoryQuery.php
+++ b/core/lib/Thelia/Model/om/BaseCategoryQuery.php
@@ -17,6 +17,7 @@ use Thelia\Model\Category;
use Thelia\Model\CategoryI18n;
use Thelia\Model\CategoryPeer;
use Thelia\Model\CategoryQuery;
+use Thelia\Model\CategoryVersion;
use Thelia\Model\ContentAssoc;
use Thelia\Model\Document;
use Thelia\Model\FeatureCategory;
@@ -36,6 +37,9 @@ use Thelia\Model\Rewriting;
* @method CategoryQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method CategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method CategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
+ * @method CategoryQuery orderByVersion($order = Criteria::ASC) Order by the version column
+ * @method CategoryQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
+ * @method CategoryQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
*
* @method CategoryQuery groupById() Group by the id column
* @method CategoryQuery groupByParent() Group by the parent column
@@ -44,6 +48,9 @@ use Thelia\Model\Rewriting;
* @method CategoryQuery groupByPosition() Group by the position column
* @method CategoryQuery groupByCreatedAt() Group by the created_at column
* @method CategoryQuery groupByUpdatedAt() Group by the updated_at column
+ * @method CategoryQuery groupByVersion() Group by the version column
+ * @method CategoryQuery groupByVersionCreatedAt() Group by the version_created_at column
+ * @method CategoryQuery groupByVersionCreatedBy() Group by the version_created_by column
*
* @method CategoryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -81,6 +88,10 @@ use Thelia\Model\Rewriting;
* @method CategoryQuery rightJoinCategoryI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryI18n relation
* @method CategoryQuery innerJoinCategoryI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryI18n relation
*
+ * @method CategoryQuery leftJoinCategoryVersion($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryVersion relation
+ * @method CategoryQuery rightJoinCategoryVersion($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryVersion relation
+ * @method CategoryQuery innerJoinCategoryVersion($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryVersion relation
+ *
* @method Category findOne(PropelPDO $con = null) Return the first Category matching the query
* @method Category findOneOrCreate(PropelPDO $con = null) Return the first Category matching the query, or a new Category object populated from the query conditions when no match is found
*
@@ -91,6 +102,9 @@ use Thelia\Model\Rewriting;
* @method Category findOneByPosition(int $position) Return the first Category filtered by the position column
* @method Category findOneByCreatedAt(string $created_at) Return the first Category filtered by the created_at column
* @method Category findOneByUpdatedAt(string $updated_at) Return the first Category filtered by the updated_at column
+ * @method Category findOneByVersion(int $version) Return the first Category filtered by the version column
+ * @method Category findOneByVersionCreatedAt(string $version_created_at) Return the first Category filtered by the version_created_at column
+ * @method Category findOneByVersionCreatedBy(string $version_created_by) Return the first Category filtered by the version_created_by column
*
* @method array findById(int $id) Return Category objects filtered by the id column
* @method array findByParent(int $parent) Return Category objects filtered by the parent column
@@ -99,6 +113,9 @@ use Thelia\Model\Rewriting;
* @method array findByPosition(int $position) Return Category objects filtered by the position column
* @method array findByCreatedAt(string $created_at) Return Category objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return Category objects filtered by the updated_at column
+ * @method array findByVersion(int $version) Return Category objects filtered by the version column
+ * @method array findByVersionCreatedAt(string $version_created_at) Return Category objects filtered by the version_created_at column
+ * @method array findByVersionCreatedBy(string $version_created_by) Return Category objects filtered by the version_created_by column
*
* @package propel.generator.Thelia.Model.om
*/
@@ -188,7 +205,7 @@ abstract class BaseCategoryQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `category` WHERE `ID` = :p0';
+ $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `category` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -542,6 +559,119 @@ abstract class BaseCategoryQuery extends ModelCriteria
return $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(CategoryPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(CategoryPeer::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(CategoryPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(CategoryPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
/**
* Filter the query by a related ProductCategory object
*
@@ -1134,6 +1264,80 @@ abstract class BaseCategoryQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CategoryI18n', '\Thelia\Model\CategoryI18nQuery');
}
+ /**
+ * Filter the query by a related CategoryVersion object
+ *
+ * @param CategoryVersion|PropelObjectCollection $categoryVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CategoryQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCategoryVersion($categoryVersion, $comparison = null)
+ {
+ if ($categoryVersion instanceof CategoryVersion) {
+ return $this
+ ->addUsingAlias(CategoryPeer::ID, $categoryVersion->getId(), $comparison);
+ } elseif ($categoryVersion instanceof PropelObjectCollection) {
+ return $this
+ ->useCategoryVersionQuery()
+ ->filterByPrimaryKeys($categoryVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCategoryVersion() only accepts arguments of type CategoryVersion or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CategoryVersion 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 joinCategoryVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CategoryVersion');
+
+ // 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, 'CategoryVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CategoryVersion relation CategoryVersion 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\CategoryVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCategoryVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CategoryVersion', '\Thelia\Model\CategoryVersionQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseCategoryVersion.php b/core/lib/Thelia/Model/om/BaseCategoryVersion.php
new file mode 100644
index 000000000..737121cc0
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategoryVersion.php
@@ -0,0 +1,1482 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseCategoryVersion 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 [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);
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return CategoryVersion 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[] = CategoryVersionPeer::ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return CategoryVersion 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[] = CategoryVersionPeer::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Set the value of [link] column.
+ *
+ * @param string $v new value
+ * @return CategoryVersion 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[] = CategoryVersionPeer::LINK;
+ }
+
+
+ return $this;
+ } // setLink()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return CategoryVersion 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[] = CategoryVersionPeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return CategoryVersion 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[] = CategoryVersionPeer::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 CategoryVersion 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[] = CategoryVersionPeer::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 CategoryVersion 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[] = CategoryVersionPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return CategoryVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = CategoryVersionPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 CategoryVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = CategoryVersionPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return CategoryVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = CategoryVersionPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * 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->version !== 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->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->version = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
+ $this->version_created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->version_created_by = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 10; // 10 = CategoryVersionPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CategoryVersion 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->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(CategoryVersionPeer::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 = CategoryVersionPeer::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(CategoryVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CategoryVersionQuery::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(CategoryVersionPeer::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);
+ CategoryVersionPeer::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;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CategoryVersionPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::PARENT)) {
+ $modifiedColumns[':p' . $index++] = '`PARENT`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::LINK)) {
+ $modifiedColumns[':p' . $index++] = '`LINK`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(CategoryVersionPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `category_version` (%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;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, 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->aCategory !== null) {
+ if (!$this->aCategory->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = CategoryVersionPeer::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 = CategoryVersionPeer::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;
+ case 7:
+ return $this->getVersion();
+ break;
+ case 8:
+ return $this->getVersionCreatedAt();
+ break;
+ case 9:
+ return $this->getVersionCreatedBy();
+ 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['CategoryVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CategoryVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = CategoryVersionPeer::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(),
+ $keys[7] => $this->getVersion(),
+ $keys[8] => $this->getVersionCreatedAt(),
+ $keys[9] => $this->getVersionCreatedBy(),
+ );
+ 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 = CategoryVersionPeer::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;
+ case 7:
+ $this->setVersion($value);
+ break;
+ case 8:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 9:
+ $this->setVersionCreatedBy($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 = CategoryVersionPeer::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]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($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(CategoryVersionPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CategoryVersionPeer::ID)) $criteria->add(CategoryVersionPeer::ID, $this->id);
+ if ($this->isColumnModified(CategoryVersionPeer::PARENT)) $criteria->add(CategoryVersionPeer::PARENT, $this->parent);
+ if ($this->isColumnModified(CategoryVersionPeer::LINK)) $criteria->add(CategoryVersionPeer::LINK, $this->link);
+ if ($this->isColumnModified(CategoryVersionPeer::VISIBLE)) $criteria->add(CategoryVersionPeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(CategoryVersionPeer::POSITION)) $criteria->add(CategoryVersionPeer::POSITION, $this->position);
+ if ($this->isColumnModified(CategoryVersionPeer::CREATED_AT)) $criteria->add(CategoryVersionPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CategoryVersionPeer::UPDATED_AT)) $criteria->add(CategoryVersionPeer::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(CategoryVersionPeer::VERSION)) $criteria->add(CategoryVersionPeer::VERSION, $this->version);
+ if ($this->isColumnModified(CategoryVersionPeer::VERSION_CREATED_AT)) $criteria->add(CategoryVersionPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(CategoryVersionPeer::VERSION_CREATED_BY)) $criteria->add(CategoryVersionPeer::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(CategoryVersionPeer::DATABASE_NAME);
+ $criteria->add(CategoryVersionPeer::ID, $this->id);
+ $criteria->add(CategoryVersionPeer::VERSION, $this->version);
+
+ 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->getVersion();
+
+ 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->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 CategoryVersion (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->setId($this->getId());
+ $copyObj->setParent($this->getParent());
+ $copyObj->setLink($this->getLink());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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 CategoryVersion 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 CategoryVersionPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CategoryVersionPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Category object.
+ *
+ * @param Category $v
+ * @return CategoryVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(Category $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($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->addCategoryVersion($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->id !== null)) {
+ $this->aCategory = CategoryQuery::create()->findPk($this->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->addCategoryVersions($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * 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->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = 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->aCategory = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CategoryVersionPeer::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/BaseCategoryVersionPeer.php b/core/lib/Thelia/Model/om/BaseCategoryVersionPeer.php
new file mode 100644
index 000000000..f8baa283e
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategoryVersionPeer.php
@@ -0,0 +1,1029 @@
+ array ('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (CategoryVersionPeer::ID, CategoryVersionPeer::PARENT, CategoryVersionPeer::LINK, CategoryVersionPeer::VISIBLE, CategoryVersionPeer::POSITION, CategoryVersionPeer::CREATED_AT, CategoryVersionPeer::UPDATED_AT, CategoryVersionPeer::VERSION, CategoryVersionPeer::VERSION_CREATED_AT, CategoryVersionPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ 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. CategoryVersionPeer::$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, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
+ BasePeer::TYPE_COLNAME => array (CategoryVersionPeer::ID => 0, CategoryVersionPeer::PARENT => 1, CategoryVersionPeer::LINK => 2, CategoryVersionPeer::VISIBLE => 3, CategoryVersionPeer::POSITION => 4, CategoryVersionPeer::CREATED_AT => 5, CategoryVersionPeer::UPDATED_AT => 6, CategoryVersionPeer::VERSION => 7, CategoryVersionPeer::VERSION_CREATED_AT => 8, CategoryVersionPeer::VERSION_CREATED_BY => 9, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 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 = CategoryVersionPeer::getFieldNames($toType);
+ $key = isset(CategoryVersionPeer::$fieldKeys[$fromType][$name]) ? CategoryVersionPeer::$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(CategoryVersionPeer::$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, CategoryVersionPeer::$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 CategoryVersionPeer::$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. CategoryVersionPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CategoryVersionPeer::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(CategoryVersionPeer::ID);
+ $criteria->addSelectColumn(CategoryVersionPeer::PARENT);
+ $criteria->addSelectColumn(CategoryVersionPeer::LINK);
+ $criteria->addSelectColumn(CategoryVersionPeer::VISIBLE);
+ $criteria->addSelectColumn(CategoryVersionPeer::POSITION);
+ $criteria->addSelectColumn(CategoryVersionPeer::CREATED_AT);
+ $criteria->addSelectColumn(CategoryVersionPeer::UPDATED_AT);
+ $criteria->addSelectColumn(CategoryVersionPeer::VERSION);
+ $criteria->addSelectColumn(CategoryVersionPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(CategoryVersionPeer::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.LINK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * 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(CategoryVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CategoryVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(CategoryVersionPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryVersionPeer::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 CategoryVersion
+ * @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 = CategoryVersionPeer::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 CategoryVersionPeer::populateObjects(CategoryVersionPeer::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(CategoryVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CategoryVersionPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryVersionPeer::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 CategoryVersion $obj A CategoryVersion 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->getVersion()));
+ } // if key === null
+ CategoryVersionPeer::$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 CategoryVersion 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 CategoryVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+ } 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 CategoryVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CategoryVersionPeer::$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 CategoryVersion 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(CategoryVersionPeer::$instances[$key])) {
+ return CategoryVersionPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ CategoryVersionPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to category_version
+ * 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 + 7] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[$startcol], (string) $row[$startcol + 7]));
+ }
+
+ /**
+ * 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 + 7]);
+ }
+
+ /**
+ * 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 = CategoryVersionPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CategoryVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CategoryVersionPeer::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;
+ CategoryVersionPeer::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 (CategoryVersion object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CategoryVersionPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CategoryVersionPeer::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 + CategoryVersionPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CategoryVersionPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CategoryVersionPeer::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(CategoryVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CategoryVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CategoryVersionPeer::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 CategoryVersion 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 CategoryVersion 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(CategoryVersionPeer::DATABASE_NAME);
+ }
+
+ CategoryVersionPeer::addSelectColumns($criteria);
+ $startcol = CategoryVersionPeer::NUM_HYDRATE_COLUMNS;
+ CategoryPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CategoryVersionPeer::ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CategoryVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CategoryVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = CategoryVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CategoryVersionPeer::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 (CategoryVersion) to $obj2 (Category)
+ $obj2->addCategoryVersion($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(CategoryVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CategoryVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CategoryVersionPeer::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 CategoryVersion 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 CategoryVersion 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(CategoryVersionPeer::DATABASE_NAME);
+ }
+
+ CategoryVersionPeer::addSelectColumns($criteria);
+ $startcol2 = CategoryVersionPeer::NUM_HYDRATE_COLUMNS;
+
+ CategoryPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CategoryVersionPeer::ID, CategoryPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CategoryVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CategoryVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = CategoryVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CategoryVersionPeer::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 (CategoryVersion) to the collection in $obj2 (Category)
+ $obj2->addCategoryVersion($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(CategoryVersionPeer::DATABASE_NAME)->getTable(CategoryVersionPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCategoryVersionPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCategoryVersionPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new CategoryVersionTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return CategoryVersionPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CategoryVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or CategoryVersion 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(CategoryVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CategoryVersion object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryVersionPeer::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 CategoryVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or CategoryVersion 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(CategoryVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CategoryVersionPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CategoryVersionPeer::ID);
+ $value = $criteria->remove(CategoryVersionPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CategoryVersionPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CategoryVersionPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(CategoryVersionPeer::VERSION);
+ $value = $criteria->remove(CategoryVersionPeer::VERSION);
+ if ($value) {
+ $selectCriteria->add(CategoryVersionPeer::VERSION, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CategoryVersionPeer::TABLE_NAME);
+ }
+
+ } else { // $values is CategoryVersion object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CategoryVersionPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the category_version 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(CategoryVersionPeer::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(CategoryVersionPeer::TABLE_NAME, $con, CategoryVersionPeer::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).
+ CategoryVersionPeer::clearInstancePool();
+ CategoryVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CategoryVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CategoryVersion 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(CategoryVersionPeer::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.
+ CategoryVersionPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof CategoryVersion) { // it's a model object
+ // invalidate the cache for this single object
+ CategoryVersionPeer::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(CategoryVersionPeer::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(CategoryVersionPeer::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CategoryVersionPeer::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ // we can invalidate the cache for this single PK
+ CategoryVersionPeer::removeInstanceFromPool($value);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryVersionPeer::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);
+ CategoryVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CategoryVersion 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 CategoryVersion $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(CategoryVersionPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CategoryVersionPeer::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(CategoryVersionPeer::DATABASE_NAME, CategoryVersionPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve object using using composite pkey values.
+ * @param int $id
+ * @param int $version
+ * @param PropelPDO $con
+ * @return CategoryVersion
+ */
+ public static function retrieveByPK($id, $version, PropelPDO $con = null) {
+ $_instancePoolKey = serialize(array((string) $id, (string) $version));
+ if (null !== ($obj = CategoryVersionPeer::getInstanceFromPool($_instancePoolKey))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CategoryVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $criteria = new Criteria(CategoryVersionPeer::DATABASE_NAME);
+ $criteria->add(CategoryVersionPeer::ID, $id);
+ $criteria->add(CategoryVersionPeer::VERSION, $version);
+ $v = CategoryVersionPeer::doSelect($criteria, $con);
+
+ return !empty($v) ? $v[0] : null;
+ }
+} // BaseCategoryVersionPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCategoryVersionPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php b/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php
new file mode 100644
index 000000000..18e567d68
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php
@@ -0,0 +1,730 @@
+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: [$id, $version]
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CategoryVersion|CategoryVersion[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CategoryVersionPeer::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(CategoryVersionPeer::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 CategoryVersion A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `category_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
+ 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 CategoryVersion();
+ $obj->hydrate($row);
+ CategoryVersionPeer::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 CategoryVersion|CategoryVersion[]|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|CategoryVersion[]|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 CategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CategoryVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CategoryVersionPeer::VERSION, $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 CategoryVersionQuery 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(CategoryVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CategoryVersionPeer::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $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
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @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 CategoryVersionQuery 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(CategoryVersionPeer::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 CategoryVersionQuery 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(CategoryVersionPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(CategoryVersionPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionPeer::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 CategoryVersionQuery 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(CategoryVersionPeer::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 CategoryVersionQuery 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(CategoryVersionPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(CategoryVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionPeer::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 CategoryVersionQuery 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(CategoryVersionPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(CategoryVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionPeer::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 CategoryVersionQuery 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(CategoryVersionPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CategoryVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionPeer::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 CategoryVersionQuery 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(CategoryVersionPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CategoryVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 CategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(CategoryVersionPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 CategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(CategoryVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(CategoryVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 CategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $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 CategoryVersionQuery 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(CategoryVersionPeer::ID, $category->getId(), $comparison);
+ } elseif ($category instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CategoryVersionPeer::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 CategoryVersionQuery 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 CategoryVersion $categoryVersion Object to remove from the list of results
+ *
+ * @return CategoryVersionQuery The current query, for fluid interface
+ */
+ public function prune($categoryVersion = null)
+ {
+ if ($categoryVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CategoryVersionPeer::ID), $categoryVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CategoryVersionPeer::VERSION), $categoryVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseContent.php b/core/lib/Thelia/Model/om/BaseContent.php
index fd45d585f..25d4e5127 100644
--- a/core/lib/Thelia/Model/om/BaseContent.php
+++ b/core/lib/Thelia/Model/om/BaseContent.php
@@ -24,6 +24,9 @@ use Thelia\Model\ContentI18n;
use Thelia\Model\ContentI18nQuery;
use Thelia\Model\ContentPeer;
use Thelia\Model\ContentQuery;
+use Thelia\Model\ContentVersion;
+use Thelia\Model\ContentVersionPeer;
+use Thelia\Model\ContentVersionQuery;
use Thelia\Model\Document;
use Thelia\Model\DocumentQuery;
use Thelia\Model\Image;
@@ -89,6 +92,25 @@ abstract class BaseContent extends BaseObject implements Persistent
*/
protected $updated_at;
+ /**
+ * The value for the version field.
+ * Note: this column has a database default value of: 0
+ * @var int
+ */
+ protected $version;
+
+ /**
+ * The value for the version_created_at field.
+ * @var string
+ */
+ protected $version_created_at;
+
+ /**
+ * The value for the version_created_by field.
+ * @var string
+ */
+ protected $version_created_by;
+
/**
* @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects.
*/
@@ -125,6 +147,12 @@ abstract class BaseContent extends BaseObject implements Persistent
protected $collContentI18ns;
protected $collContentI18nsPartial;
+ /**
+ * @var PropelObjectCollection|ContentVersion[] Collection to store aggregation of ContentVersion objects.
+ */
+ protected $collContentVersions;
+ protected $collContentVersionsPartial;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -153,6 +181,14 @@ abstract class BaseContent extends BaseObject implements Persistent
*/
protected $currentTranslations;
+ // versionable behavior
+
+
+ /**
+ * @var bool
+ */
+ protected $enforceVersion = false;
+
/**
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
@@ -189,6 +225,33 @@ abstract class BaseContent extends BaseObject implements Persistent
*/
protected $contentI18nsScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $contentVersionsScheduledForDeletion = null;
+
+ /**
+ * Applies default values to this object.
+ * This method should be called from the object's constructor (or
+ * equivalent initialization method).
+ * @see __construct()
+ */
+ public function applyDefaultValues()
+ {
+ $this->version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseContent object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
/**
* Get the [id] column value.
*
@@ -293,6 +356,63 @@ abstract class BaseContent extends BaseObject implements Persistent
}
}
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
/**
* Set the value of [id] column.
*
@@ -402,6 +522,71 @@ abstract class BaseContent extends BaseObject implements Persistent
return $this;
} // setUpdatedAt()
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return Content The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = ContentPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = ContentPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return Content The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = ContentPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -412,6 +597,10 @@ abstract class BaseContent extends BaseObject implements Persistent
*/
public function hasOnlyDefaultValues()
{
+ if ($this->version !== 0) {
+ return false;
+ }
+
// otherwise, everything was equal, so return true
return true;
} // hasOnlyDefaultValues()
@@ -439,6 +628,9 @@ abstract class BaseContent extends BaseObject implements Persistent
$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->version = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
+ $this->version_created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->version_created_by = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->resetModified();
$this->setNew(false);
@@ -447,7 +639,7 @@ abstract class BaseContent extends BaseObject implements Persistent
$this->ensureConsistency();
}
- return $startcol + 5; // 5 = ContentPeer::NUM_HYDRATE_COLUMNS.
+ return $startcol + 8; // 8 = ContentPeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Content object", $e);
@@ -521,6 +713,8 @@ abstract class BaseContent extends BaseObject implements Persistent
$this->collContentI18ns = null;
+ $this->collContentVersions = null;
+
} // if (deep)
}
@@ -591,6 +785,14 @@ abstract class BaseContent extends BaseObject implements Persistent
$isInsert = $this->isNew();
try {
$ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
if ($isInsert) {
$ret = $ret && $this->preInsert($con);
// timestampable behavior
@@ -615,6 +817,10 @@ abstract class BaseContent extends BaseObject implements Persistent
$this->postUpdate($con);
}
$this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
ContentPeer::addInstanceToPool($this);
} else {
$affectedRows = 0;
@@ -762,6 +968,23 @@ abstract class BaseContent extends BaseObject implements Persistent
}
}
+ if ($this->contentVersionsScheduledForDeletion !== null) {
+ if (!$this->contentVersionsScheduledForDeletion->isEmpty()) {
+ ContentVersionQuery::create()
+ ->filterByPrimaryKeys($this->contentVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentVersions !== null) {
+ foreach ($this->collContentVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -803,6 +1026,15 @@ abstract class BaseContent extends BaseObject implements Persistent
if ($this->isColumnModified(ContentPeer::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
}
+ if ($this->isColumnModified(ContentPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(ContentPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
$sql = sprintf(
'INSERT INTO `content` (%s) VALUES (%s)',
@@ -829,6 +1061,15 @@ abstract class BaseContent extends BaseObject implements Persistent
case '`UPDATED_AT`':
$stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
break;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
}
}
$stmt->execute();
@@ -976,6 +1217,14 @@ abstract class BaseContent extends BaseObject implements Persistent
}
}
+ if ($this->collContentVersions !== null) {
+ foreach ($this->collContentVersions as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1026,6 +1275,15 @@ abstract class BaseContent extends BaseObject implements Persistent
case 4:
return $this->getUpdatedAt();
break;
+ case 5:
+ return $this->getVersion();
+ break;
+ case 6:
+ return $this->getVersionCreatedAt();
+ break;
+ case 7:
+ return $this->getVersionCreatedBy();
+ break;
default:
return null;
break;
@@ -1060,6 +1318,9 @@ abstract class BaseContent extends BaseObject implements Persistent
$keys[2] => $this->getPosition(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
+ $keys[5] => $this->getVersion(),
+ $keys[6] => $this->getVersionCreatedAt(),
+ $keys[7] => $this->getVersionCreatedBy(),
);
if ($includeForeignObjects) {
if (null !== $this->collContentAssocs) {
@@ -1080,6 +1341,9 @@ abstract class BaseContent extends BaseObject implements Persistent
if (null !== $this->collContentI18ns) {
$result['ContentI18ns'] = $this->collContentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
+ if (null !== $this->collContentVersions) {
+ $result['ContentVersions'] = $this->collContentVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
}
return $result;
@@ -1129,6 +1393,15 @@ abstract class BaseContent extends BaseObject implements Persistent
case 4:
$this->setUpdatedAt($value);
break;
+ case 5:
+ $this->setVersion($value);
+ break;
+ case 6:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 7:
+ $this->setVersionCreatedBy($value);
+ break;
} // switch()
}
@@ -1158,6 +1431,9 @@ abstract class BaseContent extends BaseObject implements Persistent
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]]);
+ if (array_key_exists($keys[5], $arr)) $this->setVersion($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setVersionCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedBy($arr[$keys[7]]);
}
/**
@@ -1174,6 +1450,9 @@ abstract class BaseContent extends BaseObject implements Persistent
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);
+ if ($this->isColumnModified(ContentPeer::VERSION)) $criteria->add(ContentPeer::VERSION, $this->version);
+ if ($this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) $criteria->add(ContentPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(ContentPeer::VERSION_CREATED_BY)) $criteria->add(ContentPeer::VERSION_CREATED_BY, $this->version_created_by);
return $criteria;
}
@@ -1241,6 +1520,9 @@ abstract class BaseContent extends BaseObject implements Persistent
$copyObj->setPosition($this->getPosition());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@@ -1285,6 +1567,12 @@ abstract class BaseContent extends BaseObject implements Persistent
}
}
+ foreach ($this->getContentVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentVersion($relObj->copy($deepCopy));
+ }
+ }
+
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1364,6 +1652,9 @@ abstract class BaseContent extends BaseObject implements Persistent
if ('ContentI18n' == $relationName) {
$this->initContentI18ns();
}
+ if ('ContentVersion' == $relationName) {
+ $this->initContentVersions();
+ }
}
/**
@@ -2912,6 +3203,213 @@ abstract class BaseContent extends BaseObject implements Persistent
}
}
+ /**
+ * Clears out the collContentVersions 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 addContentVersions()
+ */
+ public function clearContentVersions()
+ {
+ $this->collContentVersions = null; // important to set this to null since that means it is uninitialized
+ $this->collContentVersionsPartial = null;
+ }
+
+ /**
+ * reset is the collContentVersions collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialContentVersions($v = true)
+ {
+ $this->collContentVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentVersions collection.
+ *
+ * By default this just sets the collContentVersions collection to an empty array (like clearcollContentVersions());
+ * 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 initContentVersions($overrideExisting = true)
+ {
+ if (null !== $this->collContentVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collContentVersions = new PropelObjectCollection();
+ $this->collContentVersions->setModel('ContentVersion');
+ }
+
+ /**
+ * Gets an array of ContentVersion 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|ContentVersion[] List of ContentVersion objects
+ * @throws PropelException
+ */
+ public function getContentVersions($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collContentVersionsPartial && !$this->isNew();
+ if (null === $this->collContentVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentVersions) {
+ // return empty collection
+ $this->initContentVersions();
+ } else {
+ $collContentVersions = ContentVersionQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collContentVersionsPartial && count($collContentVersions)) {
+ $this->initContentVersions(false);
+
+ foreach($collContentVersions as $obj) {
+ if (false == $this->collContentVersions->contains($obj)) {
+ $this->collContentVersions->append($obj);
+ }
+ }
+
+ $this->collContentVersionsPartial = true;
+ }
+
+ return $collContentVersions;
+ }
+
+ if($partial && $this->collContentVersions) {
+ foreach($this->collContentVersions as $obj) {
+ if($obj->isNew()) {
+ $collContentVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentVersions = $collContentVersions;
+ $this->collContentVersionsPartial = false;
+ }
+ }
+
+ return $this->collContentVersions;
+ }
+
+ /**
+ * Sets a collection of ContentVersion 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 $contentVersions A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setContentVersions(PropelCollection $contentVersions, PropelPDO $con = null)
+ {
+ $this->contentVersionsScheduledForDeletion = $this->getContentVersions(new Criteria(), $con)->diff($contentVersions);
+
+ foreach ($this->contentVersionsScheduledForDeletion as $contentVersionRemoved) {
+ $contentVersionRemoved->setContent(null);
+ }
+
+ $this->collContentVersions = null;
+ foreach ($contentVersions as $contentVersion) {
+ $this->addContentVersion($contentVersion);
+ }
+
+ $this->collContentVersions = $contentVersions;
+ $this->collContentVersionsPartial = false;
+ }
+
+ /**
+ * Returns the number of related ContentVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ContentVersion objects.
+ * @throws PropelException
+ */
+ public function countContentVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collContentVersionsPartial && !$this->isNew();
+ if (null === $this->collContentVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentVersions) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getContentVersions());
+ }
+ $query = ContentVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collContentVersions);
+ }
+ }
+
+ /**
+ * Method called to associate a ContentVersion object to this object
+ * through the ContentVersion foreign key attribute.
+ *
+ * @param ContentVersion $l ContentVersion
+ * @return Content The current object (for fluent API support)
+ */
+ public function addContentVersion(ContentVersion $l)
+ {
+ if ($this->collContentVersions === null) {
+ $this->initContentVersions();
+ $this->collContentVersionsPartial = true;
+ }
+ if (!$this->collContentVersions->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddContentVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentVersion $contentVersion The contentVersion object to add.
+ */
+ protected function doAddContentVersion($contentVersion)
+ {
+ $this->collContentVersions[]= $contentVersion;
+ $contentVersion->setContent($this);
+ }
+
+ /**
+ * @param ContentVersion $contentVersion The contentVersion object to remove.
+ */
+ public function removeContentVersion($contentVersion)
+ {
+ if ($this->getContentVersions()->contains($contentVersion)) {
+ $this->collContentVersions->remove($this->collContentVersions->search($contentVersion));
+ if (null === $this->contentVersionsScheduledForDeletion) {
+ $this->contentVersionsScheduledForDeletion = clone $this->collContentVersions;
+ $this->contentVersionsScheduledForDeletion->clear();
+ }
+ $this->contentVersionsScheduledForDeletion[]= $contentVersion;
+ $contentVersion->setContent(null);
+ }
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -2922,9 +3420,13 @@ abstract class BaseContent extends BaseObject implements Persistent
$this->position = null;
$this->created_at = null;
$this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
+ $this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
@@ -2972,6 +3474,11 @@ abstract class BaseContent extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
+ if ($this->collContentVersions) {
+ foreach ($this->collContentVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
// i18n behavior
@@ -3002,6 +3509,10 @@ abstract class BaseContent extends BaseObject implements Persistent
$this->collContentI18ns->clearIterator();
}
$this->collContentI18ns = null;
+ if ($this->collContentVersions instanceof PropelCollection) {
+ $this->collContentVersions->clearIterator();
+ }
+ $this->collContentVersions = null;
}
/**
@@ -3233,4 +3744,293 @@ abstract class BaseContent extends BaseObject implements Persistent
return $this;
}
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return Content
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @param PropelPDO $con An optional PropelPDO connection to use.
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (ContentPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return ContentVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new ContentVersion();
+ $version->setId($this->getId());
+ $version->setVisible($this->getVisible());
+ $version->setPosition($this->getPosition());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setContent($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return Content The current object (for fluent API support)
+ * @throws PropelException - if no object with the given version can be found.
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No Content object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param ContentVersion $version The version object to use
+ * @param PropelPDO $con the connection to use
+ * @param array $loadedObjects objects thats been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return Content The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+
+ $loadedObjects['Content'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setVisible($version->getVisible());
+ $this->setPosition($version->getPosition());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = ContentVersionQuery::create()
+ ->filterByContent($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return ContentVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return ContentVersionQuery::create()
+ ->filterByContent($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return PropelObjectCollection A list of ContentVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(ContentVersionPeer::VERSION);
+
+ return $this->getContentVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($this->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param integer $number the number of record to return.
+ * @param ContentVersionQuery|Criteria $criteria Additional criteria to filter.
+ * @param PropelPDO $con An optional connection to use.
+ *
+ * @return PropelCollection|ContentVersion[] List of ContentVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
+ {
+ $criteria = ContentVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(ContentVersionPeer::VERSION);
+ $criteria->limit($number);
+
+ return $this->getContentVersions($criteria, $con);
+ }
}
diff --git a/core/lib/Thelia/Model/om/BaseContentPeer.php b/core/lib/Thelia/Model/om/BaseContentPeer.php
index 1cd086b3d..15a421204 100644
--- a/core/lib/Thelia/Model/om/BaseContentPeer.php
+++ b/core/lib/Thelia/Model/om/BaseContentPeer.php
@@ -14,6 +14,7 @@ use Thelia\Model\ContentAssocPeer;
use Thelia\Model\ContentFolderPeer;
use Thelia\Model\ContentI18nPeer;
use Thelia\Model\ContentPeer;
+use Thelia\Model\ContentVersionPeer;
use Thelia\Model\DocumentPeer;
use Thelia\Model\ImagePeer;
use Thelia\Model\RewritingPeer;
@@ -42,13 +43,13 @@ abstract class BaseContentPeer
const TM_CLASS = 'ContentTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 5;
+ const NUM_COLUMNS = 8;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
- const NUM_HYDRATE_COLUMNS = 5;
+ const NUM_HYDRATE_COLUMNS = 8;
/** the column name for the ID field */
const ID = 'content.ID';
@@ -65,6 +66,15 @@ abstract class BaseContentPeer
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'content.UPDATED_AT';
+ /** the column name for the VERSION field */
+ const VERSION = 'content.VERSION';
+
+ /** the column name for the VERSION_CREATED_AT field */
+ const VERSION_CREATED_AT = 'content.VERSION_CREATED_AT';
+
+ /** the column name for the VERSION_CREATED_BY field */
+ const VERSION_CREATED_BY = 'content.VERSION_CREATED_BY';
+
/** The default string format for model objects of the related table **/
const DEFAULT_STRING_FORMAT = 'YAML';
@@ -84,6 +94,13 @@ abstract class BaseContentPeer
* @var string
*/
const DEFAULT_LOCALE = 'en_EN';
+ // versionable behavior
+
+ /**
+ * Whether the versioning is enabled
+ */
+ static $isVersioningEnabled = true;
+
/**
* holds an array of fieldnames
*
@@ -91,12 +108,12 @@ abstract class BaseContentPeer
* e.g. ContentPeer::$fieldNames[ContentPeer::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => 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, )
+ BasePeer::TYPE_PHPNAME => array ('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (ContentPeer::ID, ContentPeer::VISIBLE, ContentPeer::POSITION, ContentPeer::CREATED_AT, ContentPeer::UPDATED_AT, ContentPeer::VERSION, ContentPeer::VERSION_CREATED_AT, ContentPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@@ -106,12 +123,12 @@ abstract class BaseContentPeer
* 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, )
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, 'Version' => 5, 'VersionCreatedAt' => 6, 'VersionCreatedBy' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, 'version' => 5, 'versionCreatedAt' => 6, 'versionCreatedBy' => 7, ),
+ BasePeer::TYPE_COLNAME => array (ContentPeer::ID => 0, ContentPeer::VISIBLE => 1, ContentPeer::POSITION => 2, ContentPeer::CREATED_AT => 3, ContentPeer::UPDATED_AT => 4, ContentPeer::VERSION => 5, ContentPeer::VERSION_CREATED_AT => 6, ContentPeer::VERSION_CREATED_BY => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, 'VERSION' => 5, 'VERSION_CREATED_AT' => 6, 'VERSION_CREATED_BY' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, 'version' => 5, 'version_created_at' => 6, 'version_created_by' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@@ -190,12 +207,18 @@ abstract class BaseContentPeer
$criteria->addSelectColumn(ContentPeer::POSITION);
$criteria->addSelectColumn(ContentPeer::CREATED_AT);
$criteria->addSelectColumn(ContentPeer::UPDATED_AT);
+ $criteria->addSelectColumn(ContentPeer::VERSION);
+ $criteria->addSelectColumn(ContentPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(ContentPeer::VERSION_CREATED_BY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.VISIBLE');
$criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
}
}
@@ -413,6 +436,9 @@ abstract class BaseContentPeer
// Invalidate objects in ContentI18nPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
ContentI18nPeer::clearInstancePool();
+ // Invalidate objects in ContentVersionPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ContentVersionPeer::clearInstancePool();
}
/**
@@ -806,6 +832,34 @@ abstract class BaseContentPeer
return $objs;
}
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ public static function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ public static function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ public static function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
} // BaseContentPeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
diff --git a/core/lib/Thelia/Model/om/BaseContentQuery.php b/core/lib/Thelia/Model/om/BaseContentQuery.php
index abe322ca8..1c520e69b 100644
--- a/core/lib/Thelia/Model/om/BaseContentQuery.php
+++ b/core/lib/Thelia/Model/om/BaseContentQuery.php
@@ -18,6 +18,7 @@ use Thelia\Model\ContentFolder;
use Thelia\Model\ContentI18n;
use Thelia\Model\ContentPeer;
use Thelia\Model\ContentQuery;
+use Thelia\Model\ContentVersion;
use Thelia\Model\Document;
use Thelia\Model\Image;
use Thelia\Model\Rewriting;
@@ -32,12 +33,18 @@ use Thelia\Model\Rewriting;
* @method ContentQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ContentQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ContentQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
+ * @method ContentQuery orderByVersion($order = Criteria::ASC) Order by the version column
+ * @method ContentQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
+ * @method ContentQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
*
* @method ContentQuery groupById() Group by the id column
* @method ContentQuery groupByVisible() Group by the visible column
* @method ContentQuery groupByPosition() Group by the position column
* @method ContentQuery groupByCreatedAt() Group by the created_at column
* @method ContentQuery groupByUpdatedAt() Group by the updated_at column
+ * @method ContentQuery groupByVersion() Group by the version column
+ * @method ContentQuery groupByVersionCreatedAt() Group by the version_created_at column
+ * @method ContentQuery groupByVersionCreatedBy() Group by the version_created_by column
*
* @method ContentQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ContentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -67,6 +74,10 @@ use Thelia\Model\Rewriting;
* @method ContentQuery rightJoinContentI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentI18n relation
* @method ContentQuery innerJoinContentI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentI18n relation
*
+ * @method ContentQuery leftJoinContentVersion($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentVersion relation
+ * @method ContentQuery rightJoinContentVersion($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentVersion relation
+ * @method ContentQuery innerJoinContentVersion($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentVersion relation
+ *
* @method Content findOne(PropelPDO $con = null) Return the first Content matching the query
* @method Content findOneOrCreate(PropelPDO $con = null) Return the first Content matching the query, or a new Content object populated from the query conditions when no match is found
*
@@ -75,12 +86,18 @@ use Thelia\Model\Rewriting;
* @method Content findOneByPosition(int $position) Return the first Content filtered by the position column
* @method Content findOneByCreatedAt(string $created_at) Return the first Content filtered by the created_at column
* @method Content findOneByUpdatedAt(string $updated_at) Return the first Content filtered by the updated_at column
+ * @method Content findOneByVersion(int $version) Return the first Content filtered by the version column
+ * @method Content findOneByVersionCreatedAt(string $version_created_at) Return the first Content filtered by the version_created_at column
+ * @method Content findOneByVersionCreatedBy(string $version_created_by) Return the first Content filtered by the version_created_by column
*
* @method array findById(int $id) Return Content objects filtered by the id column
* @method array findByVisible(int $visible) Return Content objects filtered by the visible column
* @method array findByPosition(int $position) Return Content objects filtered by the position column
* @method array findByCreatedAt(string $created_at) Return Content objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return Content objects filtered by the updated_at column
+ * @method array findByVersion(int $version) Return Content objects filtered by the version column
+ * @method array findByVersionCreatedAt(string $version_created_at) Return Content objects filtered by the version_created_at column
+ * @method array findByVersionCreatedBy(string $version_created_by) Return Content objects filtered by the version_created_by column
*
* @package propel.generator.Thelia.Model.om
*/
@@ -170,7 +187,7 @@ abstract class BaseContentQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `content` WHERE `ID` = :p0';
+ $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `content` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -454,6 +471,119 @@ abstract class BaseContentQuery extends ModelCriteria
return $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(ContentPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(ContentPeer::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(ContentPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(ContentPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 ContentQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
/**
* Filter the query by a related ContentAssoc object
*
@@ -898,6 +1028,80 @@ abstract class BaseContentQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'ContentI18n', '\Thelia\Model\ContentI18nQuery');
}
+ /**
+ * Filter the query by a related ContentVersion object
+ *
+ * @param ContentVersion|PropelObjectCollection $contentVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ContentQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByContentVersion($contentVersion, $comparison = null)
+ {
+ if ($contentVersion instanceof ContentVersion) {
+ return $this
+ ->addUsingAlias(ContentPeer::ID, $contentVersion->getId(), $comparison);
+ } elseif ($contentVersion instanceof PropelObjectCollection) {
+ return $this
+ ->useContentVersionQuery()
+ ->filterByPrimaryKeys($contentVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentVersion() only accepts arguments of type ContentVersion or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentVersion 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 joinContentVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentVersion');
+
+ // 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, 'ContentVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentVersion relation ContentVersion 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\ContentVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useContentVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContentVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentVersion', '\Thelia\Model\ContentVersionQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseContentVersion.php b/core/lib/Thelia/Model/om/BaseContentVersion.php
new file mode 100644
index 000000000..b6bc1d06c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentVersion.php
@@ -0,0 +1,1372 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseContentVersion 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);
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ContentVersion 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[] = ContentVersionPeer::ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return ContentVersion 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[] = ContentVersionPeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return ContentVersion 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[] = ContentVersionPeer::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 ContentVersion 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[] = ContentVersionPeer::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 ContentVersion 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[] = ContentVersionPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return ContentVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = ContentVersionPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 ContentVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = ContentVersionPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return ContentVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = ContentVersionPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * 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->version !== 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->version = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
+ $this->version_created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->version_created_by = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = ContentVersionPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ContentVersion 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->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(ContentVersionPeer::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 = ContentVersionPeer::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(ContentVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ContentVersionQuery::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(ContentVersionPeer::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);
+ ContentVersionPeer::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;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentVersionPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ContentVersionPeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(ContentVersionPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(ContentVersionPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ContentVersionPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+ if ($this->isColumnModified(ContentVersionPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(ContentVersionPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(ContentVersionPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `content_version` (%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;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, 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->aContent !== null) {
+ if (!$this->aContent->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = ContentVersionPeer::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 = ContentVersionPeer::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;
+ case 5:
+ return $this->getVersion();
+ break;
+ case 6:
+ return $this->getVersionCreatedAt();
+ break;
+ case 7:
+ return $this->getVersionCreatedBy();
+ 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['ContentVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ContentVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = ContentVersionPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getVisible(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ $keys[5] => $this->getVersion(),
+ $keys[6] => $this->getVersionCreatedAt(),
+ $keys[7] => $this->getVersionCreatedBy(),
+ );
+ 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 = ContentVersionPeer::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;
+ case 5:
+ $this->setVersion($value);
+ break;
+ case 6:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 7:
+ $this->setVersionCreatedBy($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 = ContentVersionPeer::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]]);
+ if (array_key_exists($keys[5], $arr)) $this->setVersion($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setVersionCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedBy($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(ContentVersionPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentVersionPeer::ID)) $criteria->add(ContentVersionPeer::ID, $this->id);
+ if ($this->isColumnModified(ContentVersionPeer::VISIBLE)) $criteria->add(ContentVersionPeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(ContentVersionPeer::POSITION)) $criteria->add(ContentVersionPeer::POSITION, $this->position);
+ if ($this->isColumnModified(ContentVersionPeer::CREATED_AT)) $criteria->add(ContentVersionPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ContentVersionPeer::UPDATED_AT)) $criteria->add(ContentVersionPeer::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(ContentVersionPeer::VERSION)) $criteria->add(ContentVersionPeer::VERSION, $this->version);
+ if ($this->isColumnModified(ContentVersionPeer::VERSION_CREATED_AT)) $criteria->add(ContentVersionPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(ContentVersionPeer::VERSION_CREATED_BY)) $criteria->add(ContentVersionPeer::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(ContentVersionPeer::DATABASE_NAME);
+ $criteria->add(ContentVersionPeer::ID, $this->id);
+ $criteria->add(ContentVersionPeer::VERSION, $this->version);
+
+ 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->getVersion();
+
+ 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->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 ContentVersion (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->setId($this->getId());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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 ContentVersion 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 ContentVersionPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ContentVersionPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Content object.
+ *
+ * @param Content $v
+ * @return ContentVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(Content $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($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->addContentVersion($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->id !== null)) {
+ $this->aContent = ContentQuery::create()->findPk($this->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->addContentVersions($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * 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->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = 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->aContent = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentVersionPeer::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/BaseContentVersionPeer.php b/core/lib/Thelia/Model/om/BaseContentVersionPeer.php
new file mode 100644
index 000000000..c734a84bd
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentVersionPeer.php
@@ -0,0 +1,1019 @@
+ array ('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (ContentVersionPeer::ID, ContentVersionPeer::VISIBLE, ContentVersionPeer::POSITION, ContentVersionPeer::CREATED_AT, ContentVersionPeer::UPDATED_AT, ContentVersionPeer::VERSION, ContentVersionPeer::VERSION_CREATED_AT, ContentVersionPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ 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. ContentVersionPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, 'Version' => 5, 'VersionCreatedAt' => 6, 'VersionCreatedBy' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, 'version' => 5, 'versionCreatedAt' => 6, 'versionCreatedBy' => 7, ),
+ BasePeer::TYPE_COLNAME => array (ContentVersionPeer::ID => 0, ContentVersionPeer::VISIBLE => 1, ContentVersionPeer::POSITION => 2, ContentVersionPeer::CREATED_AT => 3, ContentVersionPeer::UPDATED_AT => 4, ContentVersionPeer::VERSION => 5, ContentVersionPeer::VERSION_CREATED_AT => 6, ContentVersionPeer::VERSION_CREATED_BY => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, 'VERSION' => 5, 'VERSION_CREATED_AT' => 6, 'VERSION_CREATED_BY' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, 'version' => 5, 'version_created_at' => 6, 'version_created_by' => 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 = ContentVersionPeer::getFieldNames($toType);
+ $key = isset(ContentVersionPeer::$fieldKeys[$fromType][$name]) ? ContentVersionPeer::$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(ContentVersionPeer::$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, ContentVersionPeer::$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 ContentVersionPeer::$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. ContentVersionPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ContentVersionPeer::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(ContentVersionPeer::ID);
+ $criteria->addSelectColumn(ContentVersionPeer::VISIBLE);
+ $criteria->addSelectColumn(ContentVersionPeer::POSITION);
+ $criteria->addSelectColumn(ContentVersionPeer::CREATED_AT);
+ $criteria->addSelectColumn(ContentVersionPeer::UPDATED_AT);
+ $criteria->addSelectColumn(ContentVersionPeer::VERSION);
+ $criteria->addSelectColumn(ContentVersionPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(ContentVersionPeer::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * 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(ContentVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(ContentVersionPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentVersionPeer::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 ContentVersion
+ * @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 = ContentVersionPeer::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 ContentVersionPeer::populateObjects(ContentVersionPeer::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(ContentVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ContentVersionPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentVersionPeer::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 ContentVersion $obj A ContentVersion 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->getVersion()));
+ } // if key === null
+ ContentVersionPeer::$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 ContentVersion 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 ContentVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+ } 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 ContentVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ContentVersionPeer::$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 ContentVersion 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(ContentVersionPeer::$instances[$key])) {
+ return ContentVersionPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ContentVersionPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to content_version
+ * 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 + 5] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[$startcol], (string) $row[$startcol + 5]));
+ }
+
+ /**
+ * 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 + 5]);
+ }
+
+ /**
+ * 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 = ContentVersionPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ContentVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ContentVersionPeer::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;
+ ContentVersionPeer::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 (ContentVersion object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ContentVersionPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ContentVersionPeer::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 + ContentVersionPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentVersionPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ContentVersionPeer::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(ContentVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentVersionPeer::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 ContentVersion 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 ContentVersion 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(ContentVersionPeer::DATABASE_NAME);
+ }
+
+ ContentVersionPeer::addSelectColumns($criteria);
+ $startcol = ContentVersionPeer::NUM_HYDRATE_COLUMNS;
+ ContentPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ContentVersionPeer::ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ContentVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentVersionPeer::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 (ContentVersion) to $obj2 (Content)
+ $obj2->addContentVersion($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(ContentVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ContentVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ContentVersionPeer::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 ContentVersion 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 ContentVersion 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(ContentVersionPeer::DATABASE_NAME);
+ }
+
+ ContentVersionPeer::addSelectColumns($criteria);
+ $startcol2 = ContentVersionPeer::NUM_HYDRATE_COLUMNS;
+
+ ContentPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ContentPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ContentVersionPeer::ID, ContentPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ContentVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ContentVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ContentVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ContentVersionPeer::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 (ContentVersion) to the collection in $obj2 (Content)
+ $obj2->addContentVersion($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(ContentVersionPeer::DATABASE_NAME)->getTable(ContentVersionPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseContentVersionPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseContentVersionPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentVersionTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ContentVersionPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ContentVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or ContentVersion 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(ContentVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ContentVersion object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentVersionPeer::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 ContentVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or ContentVersion 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(ContentVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ContentVersionPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ContentVersionPeer::ID);
+ $value = $criteria->remove(ContentVersionPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ContentVersionPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ContentVersionPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(ContentVersionPeer::VERSION);
+ $value = $criteria->remove(ContentVersionPeer::VERSION);
+ if ($value) {
+ $selectCriteria->add(ContentVersionPeer::VERSION, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ContentVersionPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ContentVersion object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ContentVersionPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the content_version 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(ContentVersionPeer::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(ContentVersionPeer::TABLE_NAME, $con, ContentVersionPeer::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).
+ ContentVersionPeer::clearInstancePool();
+ ContentVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ContentVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ContentVersion 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(ContentVersionPeer::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.
+ ContentVersionPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof ContentVersion) { // it's a model object
+ // invalidate the cache for this single object
+ ContentVersionPeer::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(ContentVersionPeer::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(ContentVersionPeer::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ContentVersionPeer::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ // we can invalidate the cache for this single PK
+ ContentVersionPeer::removeInstanceFromPool($value);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentVersionPeer::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);
+ ContentVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ContentVersion 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 ContentVersion $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(ContentVersionPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ContentVersionPeer::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(ContentVersionPeer::DATABASE_NAME, ContentVersionPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve object using using composite pkey values.
+ * @param int $id
+ * @param int $version
+ * @param PropelPDO $con
+ * @return ContentVersion
+ */
+ public static function retrieveByPK($id, $version, PropelPDO $con = null) {
+ $_instancePoolKey = serialize(array((string) $id, (string) $version));
+ if (null !== ($obj = ContentVersionPeer::getInstanceFromPool($_instancePoolKey))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ContentVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $criteria = new Criteria(ContentVersionPeer::DATABASE_NAME);
+ $criteria->add(ContentVersionPeer::ID, $id);
+ $criteria->add(ContentVersionPeer::VERSION, $version);
+ $v = ContentVersionPeer::doSelect($criteria, $con);
+
+ return !empty($v) ? $v[0] : null;
+ }
+} // BaseContentVersionPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseContentVersionPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseContentVersionQuery.php b/core/lib/Thelia/Model/om/BaseContentVersionQuery.php
new file mode 100644
index 000000000..fa736c86b
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseContentVersionQuery.php
@@ -0,0 +1,652 @@
+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: [$id, $version]
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ContentVersion|ContentVersion[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentVersionPeer::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(ContentVersionPeer::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 ContentVersion A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `content_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
+ 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 ContentVersion();
+ $obj->hydrate($row);
+ ContentVersionPeer::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 ContentVersion|ContentVersion[]|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|ContentVersion[]|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 ContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ContentVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ContentVersionPeer::VERSION, $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 ContentVersionQuery 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(ContentVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ContentVersionPeer::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $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
+ *
+ *
+ * @see filterByContent()
+ *
+ * @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 ContentVersionQuery 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(ContentVersionPeer::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 ContentVersionQuery 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(ContentVersionPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(ContentVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionPeer::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 ContentVersionQuery 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(ContentVersionPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ContentVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionPeer::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 ContentVersionQuery 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(ContentVersionPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ContentVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionPeer::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 ContentVersionQuery 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(ContentVersionPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ContentVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 ContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ContentVersionPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 ContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(ContentVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(ContentVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 ContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $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 ContentVersionQuery 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(ContentVersionPeer::ID, $content->getId(), $comparison);
+ } elseif ($content instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentVersionPeer::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 ContentVersionQuery 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 ContentVersion $contentVersion Object to remove from the list of results
+ *
+ * @return ContentVersionQuery The current query, for fluid interface
+ */
+ public function prune($contentVersion = null)
+ {
+ if ($contentVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ContentVersionPeer::ID), $contentVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ContentVersionPeer::VERSION), $contentVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseFolder.php b/core/lib/Thelia/Model/om/BaseFolder.php
index 3824c8973..7740b7329 100644
--- a/core/lib/Thelia/Model/om/BaseFolder.php
+++ b/core/lib/Thelia/Model/om/BaseFolder.php
@@ -24,6 +24,9 @@ use Thelia\Model\FolderI18n;
use Thelia\Model\FolderI18nQuery;
use Thelia\Model\FolderPeer;
use Thelia\Model\FolderQuery;
+use Thelia\Model\FolderVersion;
+use Thelia\Model\FolderVersionPeer;
+use Thelia\Model\FolderVersionQuery;
use Thelia\Model\Image;
use Thelia\Model\ImageQuery;
use Thelia\Model\Rewriting;
@@ -99,6 +102,25 @@ abstract class BaseFolder extends BaseObject implements Persistent
*/
protected $updated_at;
+ /**
+ * The value for the version field.
+ * Note: this column has a database default value of: 0
+ * @var int
+ */
+ protected $version;
+
+ /**
+ * The value for the version_created_at field.
+ * @var string
+ */
+ protected $version_created_at;
+
+ /**
+ * The value for the version_created_by field.
+ * @var string
+ */
+ protected $version_created_by;
+
/**
* @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects.
*/
@@ -129,6 +151,12 @@ abstract class BaseFolder extends BaseObject implements Persistent
protected $collFolderI18ns;
protected $collFolderI18nsPartial;
+ /**
+ * @var PropelObjectCollection|FolderVersion[] Collection to store aggregation of FolderVersion objects.
+ */
+ protected $collFolderVersions;
+ protected $collFolderVersionsPartial;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -157,6 +185,14 @@ abstract class BaseFolder extends BaseObject implements Persistent
*/
protected $currentTranslations;
+ // versionable behavior
+
+
+ /**
+ * @var bool
+ */
+ protected $enforceVersion = false;
+
/**
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
@@ -187,6 +223,33 @@ abstract class BaseFolder extends BaseObject implements Persistent
*/
protected $folderI18nsScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $folderVersionsScheduledForDeletion = null;
+
+ /**
+ * Applies default values to this object.
+ * This method should be called from the object's constructor (or
+ * equivalent initialization method).
+ * @see __construct()
+ */
+ public function applyDefaultValues()
+ {
+ $this->version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseFolder object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
/**
* Get the [id] column value.
*
@@ -311,6 +374,63 @@ abstract class BaseFolder extends BaseObject implements Persistent
}
}
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
/**
* Set the value of [id] column.
*
@@ -462,6 +582,71 @@ abstract class BaseFolder extends BaseObject implements Persistent
return $this;
} // setUpdatedAt()
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = FolderPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = FolderPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return Folder The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = FolderPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -472,6 +657,10 @@ abstract class BaseFolder extends BaseObject implements Persistent
*/
public function hasOnlyDefaultValues()
{
+ if ($this->version !== 0) {
+ return false;
+ }
+
// otherwise, everything was equal, so return true
return true;
} // hasOnlyDefaultValues()
@@ -501,6 +690,9 @@ abstract class BaseFolder extends BaseObject implements Persistent
$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->version = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
+ $this->version_created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->version_created_by = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
$this->resetModified();
$this->setNew(false);
@@ -509,7 +701,7 @@ abstract class BaseFolder extends BaseObject implements Persistent
$this->ensureConsistency();
}
- return $startcol + 7; // 7 = FolderPeer::NUM_HYDRATE_COLUMNS.
+ return $startcol + 10; // 10 = FolderPeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Folder object", $e);
@@ -581,6 +773,8 @@ abstract class BaseFolder extends BaseObject implements Persistent
$this->collFolderI18ns = null;
+ $this->collFolderVersions = null;
+
} // if (deep)
}
@@ -651,6 +845,14 @@ abstract class BaseFolder extends BaseObject implements Persistent
$isInsert = $this->isNew();
try {
$ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
if ($isInsert) {
$ret = $ret && $this->preInsert($con);
// timestampable behavior
@@ -675,6 +877,10 @@ abstract class BaseFolder extends BaseObject implements Persistent
$this->postUpdate($con);
}
$this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
FolderPeer::addInstanceToPool($this);
} else {
$affectedRows = 0;
@@ -804,6 +1010,23 @@ abstract class BaseFolder extends BaseObject implements Persistent
}
}
+ if ($this->folderVersionsScheduledForDeletion !== null) {
+ if (!$this->folderVersionsScheduledForDeletion->isEmpty()) {
+ FolderVersionQuery::create()
+ ->filterByPrimaryKeys($this->folderVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->folderVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFolderVersions !== null) {
+ foreach ($this->collFolderVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -851,6 +1074,15 @@ abstract class BaseFolder extends BaseObject implements Persistent
if ($this->isColumnModified(FolderPeer::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
}
+ if ($this->isColumnModified(FolderPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(FolderPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
$sql = sprintf(
'INSERT INTO `folder` (%s) VALUES (%s)',
@@ -883,6 +1115,15 @@ abstract class BaseFolder extends BaseObject implements Persistent
case '`UPDATED_AT`':
$stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
break;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
}
}
$stmt->execute();
@@ -1022,6 +1263,14 @@ abstract class BaseFolder extends BaseObject implements Persistent
}
}
+ if ($this->collFolderVersions !== null) {
+ foreach ($this->collFolderVersions as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1078,6 +1327,15 @@ abstract class BaseFolder extends BaseObject implements Persistent
case 6:
return $this->getUpdatedAt();
break;
+ case 7:
+ return $this->getVersion();
+ break;
+ case 8:
+ return $this->getVersionCreatedAt();
+ break;
+ case 9:
+ return $this->getVersionCreatedBy();
+ break;
default:
return null;
break;
@@ -1114,6 +1372,9 @@ abstract class BaseFolder extends BaseObject implements Persistent
$keys[4] => $this->getPosition(),
$keys[5] => $this->getCreatedAt(),
$keys[6] => $this->getUpdatedAt(),
+ $keys[7] => $this->getVersion(),
+ $keys[8] => $this->getVersionCreatedAt(),
+ $keys[9] => $this->getVersionCreatedBy(),
);
if ($includeForeignObjects) {
if (null !== $this->collImages) {
@@ -1131,6 +1392,9 @@ abstract class BaseFolder extends BaseObject implements Persistent
if (null !== $this->collFolderI18ns) {
$result['FolderI18ns'] = $this->collFolderI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
+ if (null !== $this->collFolderVersions) {
+ $result['FolderVersions'] = $this->collFolderVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
}
return $result;
@@ -1186,6 +1450,15 @@ abstract class BaseFolder extends BaseObject implements Persistent
case 6:
$this->setUpdatedAt($value);
break;
+ case 7:
+ $this->setVersion($value);
+ break;
+ case 8:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 9:
+ $this->setVersionCreatedBy($value);
+ break;
} // switch()
}
@@ -1217,6 +1490,9 @@ abstract class BaseFolder extends BaseObject implements Persistent
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]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
}
/**
@@ -1235,6 +1511,9 @@ abstract class BaseFolder extends BaseObject implements Persistent
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);
+ if ($this->isColumnModified(FolderPeer::VERSION)) $criteria->add(FolderPeer::VERSION, $this->version);
+ if ($this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) $criteria->add(FolderPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(FolderPeer::VERSION_CREATED_BY)) $criteria->add(FolderPeer::VERSION_CREATED_BY, $this->version_created_by);
return $criteria;
}
@@ -1304,6 +1583,9 @@ abstract class BaseFolder extends BaseObject implements Persistent
$copyObj->setPosition($this->getPosition());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@@ -1342,6 +1624,12 @@ abstract class BaseFolder extends BaseObject implements Persistent
}
}
+ foreach ($this->getFolderVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFolderVersion($relObj->copy($deepCopy));
+ }
+ }
+
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1418,6 +1706,9 @@ abstract class BaseFolder extends BaseObject implements Persistent
if ('FolderI18n' == $relationName) {
$this->initFolderI18ns();
}
+ if ('FolderVersion' == $relationName) {
+ $this->initFolderVersions();
+ }
}
/**
@@ -2709,6 +3000,213 @@ abstract class BaseFolder extends BaseObject implements Persistent
}
}
+ /**
+ * Clears out the collFolderVersions 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 addFolderVersions()
+ */
+ public function clearFolderVersions()
+ {
+ $this->collFolderVersions = null; // important to set this to null since that means it is uninitialized
+ $this->collFolderVersionsPartial = null;
+ }
+
+ /**
+ * reset is the collFolderVersions collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialFolderVersions($v = true)
+ {
+ $this->collFolderVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFolderVersions collection.
+ *
+ * By default this just sets the collFolderVersions collection to an empty array (like clearcollFolderVersions());
+ * 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 initFolderVersions($overrideExisting = true)
+ {
+ if (null !== $this->collFolderVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collFolderVersions = new PropelObjectCollection();
+ $this->collFolderVersions->setModel('FolderVersion');
+ }
+
+ /**
+ * Gets an array of FolderVersion 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|FolderVersion[] List of FolderVersion objects
+ * @throws PropelException
+ */
+ public function getFolderVersions($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collFolderVersionsPartial && !$this->isNew();
+ if (null === $this->collFolderVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFolderVersions) {
+ // return empty collection
+ $this->initFolderVersions();
+ } else {
+ $collFolderVersions = FolderVersionQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collFolderVersionsPartial && count($collFolderVersions)) {
+ $this->initFolderVersions(false);
+
+ foreach($collFolderVersions as $obj) {
+ if (false == $this->collFolderVersions->contains($obj)) {
+ $this->collFolderVersions->append($obj);
+ }
+ }
+
+ $this->collFolderVersionsPartial = true;
+ }
+
+ return $collFolderVersions;
+ }
+
+ if($partial && $this->collFolderVersions) {
+ foreach($this->collFolderVersions as $obj) {
+ if($obj->isNew()) {
+ $collFolderVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collFolderVersions = $collFolderVersions;
+ $this->collFolderVersionsPartial = false;
+ }
+ }
+
+ return $this->collFolderVersions;
+ }
+
+ /**
+ * Sets a collection of FolderVersion 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 $folderVersions A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setFolderVersions(PropelCollection $folderVersions, PropelPDO $con = null)
+ {
+ $this->folderVersionsScheduledForDeletion = $this->getFolderVersions(new Criteria(), $con)->diff($folderVersions);
+
+ foreach ($this->folderVersionsScheduledForDeletion as $folderVersionRemoved) {
+ $folderVersionRemoved->setFolder(null);
+ }
+
+ $this->collFolderVersions = null;
+ foreach ($folderVersions as $folderVersion) {
+ $this->addFolderVersion($folderVersion);
+ }
+
+ $this->collFolderVersions = $folderVersions;
+ $this->collFolderVersionsPartial = false;
+ }
+
+ /**
+ * Returns the number of related FolderVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related FolderVersion objects.
+ * @throws PropelException
+ */
+ public function countFolderVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collFolderVersionsPartial && !$this->isNew();
+ if (null === $this->collFolderVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFolderVersions) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getFolderVersions());
+ }
+ $query = FolderVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collFolderVersions);
+ }
+ }
+
+ /**
+ * Method called to associate a FolderVersion object to this object
+ * through the FolderVersion foreign key attribute.
+ *
+ * @param FolderVersion $l FolderVersion
+ * @return Folder The current object (for fluent API support)
+ */
+ public function addFolderVersion(FolderVersion $l)
+ {
+ if ($this->collFolderVersions === null) {
+ $this->initFolderVersions();
+ $this->collFolderVersionsPartial = true;
+ }
+ if (!$this->collFolderVersions->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddFolderVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FolderVersion $folderVersion The folderVersion object to add.
+ */
+ protected function doAddFolderVersion($folderVersion)
+ {
+ $this->collFolderVersions[]= $folderVersion;
+ $folderVersion->setFolder($this);
+ }
+
+ /**
+ * @param FolderVersion $folderVersion The folderVersion object to remove.
+ */
+ public function removeFolderVersion($folderVersion)
+ {
+ if ($this->getFolderVersions()->contains($folderVersion)) {
+ $this->collFolderVersions->remove($this->collFolderVersions->search($folderVersion));
+ if (null === $this->folderVersionsScheduledForDeletion) {
+ $this->folderVersionsScheduledForDeletion = clone $this->collFolderVersions;
+ $this->folderVersionsScheduledForDeletion->clear();
+ }
+ $this->folderVersionsScheduledForDeletion[]= $folderVersion;
+ $folderVersion->setFolder(null);
+ }
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -2721,9 +3219,13 @@ abstract class BaseFolder extends BaseObject implements Persistent
$this->position = null;
$this->created_at = null;
$this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
+ $this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
@@ -2766,6 +3268,11 @@ abstract class BaseFolder extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
+ if ($this->collFolderVersions) {
+ foreach ($this->collFolderVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
// i18n behavior
@@ -2792,6 +3299,10 @@ abstract class BaseFolder extends BaseObject implements Persistent
$this->collFolderI18ns->clearIterator();
}
$this->collFolderI18ns = null;
+ if ($this->collFolderVersions instanceof PropelCollection) {
+ $this->collFolderVersions->clearIterator();
+ }
+ $this->collFolderVersions = null;
}
/**
@@ -3023,4 +3534,297 @@ abstract class BaseFolder extends BaseObject implements Persistent
return $this;
}
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return Folder
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @param PropelPDO $con An optional PropelPDO connection to use.
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (FolderPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return FolderVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new FolderVersion();
+ $version->setId($this->getId());
+ $version->setParent($this->getParent());
+ $version->setLink($this->getLink());
+ $version->setVisible($this->getVisible());
+ $version->setPosition($this->getPosition());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setFolder($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return Folder The current object (for fluent API support)
+ * @throws PropelException - if no object with the given version can be found.
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No Folder object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param FolderVersion $version The version object to use
+ * @param PropelPDO $con the connection to use
+ * @param array $loadedObjects objects thats been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return Folder The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+
+ $loadedObjects['Folder'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setParent($version->getParent());
+ $this->setLink($version->getLink());
+ $this->setVisible($version->getVisible());
+ $this->setPosition($version->getPosition());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = FolderVersionQuery::create()
+ ->filterByFolder($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return FolderVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return FolderVersionQuery::create()
+ ->filterByFolder($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return PropelObjectCollection A list of FolderVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(FolderVersionPeer::VERSION);
+
+ return $this->getFolderVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($this->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param integer $number the number of record to return.
+ * @param FolderVersionQuery|Criteria $criteria Additional criteria to filter.
+ * @param PropelPDO $con An optional connection to use.
+ *
+ * @return PropelCollection|FolderVersion[] List of FolderVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
+ {
+ $criteria = FolderVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(FolderVersionPeer::VERSION);
+ $criteria->limit($number);
+
+ return $this->getFolderVersions($criteria, $con);
+ }
}
diff --git a/core/lib/Thelia/Model/om/BaseFolderPeer.php b/core/lib/Thelia/Model/om/BaseFolderPeer.php
index 6eea02ea4..1399a3f3f 100644
--- a/core/lib/Thelia/Model/om/BaseFolderPeer.php
+++ b/core/lib/Thelia/Model/om/BaseFolderPeer.php
@@ -14,6 +14,7 @@ use Thelia\Model\DocumentPeer;
use Thelia\Model\Folder;
use Thelia\Model\FolderI18nPeer;
use Thelia\Model\FolderPeer;
+use Thelia\Model\FolderVersionPeer;
use Thelia\Model\ImagePeer;
use Thelia\Model\RewritingPeer;
use Thelia\Model\map\FolderTableMap;
@@ -41,13 +42,13 @@ abstract class BaseFolderPeer
const TM_CLASS = 'FolderTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 7;
+ const NUM_COLUMNS = 10;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
- const NUM_HYDRATE_COLUMNS = 7;
+ const NUM_HYDRATE_COLUMNS = 10;
/** the column name for the ID field */
const ID = 'folder.ID';
@@ -70,6 +71,15 @@ abstract class BaseFolderPeer
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'folder.UPDATED_AT';
+ /** the column name for the VERSION field */
+ const VERSION = 'folder.VERSION';
+
+ /** the column name for the VERSION_CREATED_AT field */
+ const VERSION_CREATED_AT = 'folder.VERSION_CREATED_AT';
+
+ /** the column name for the VERSION_CREATED_BY field */
+ const VERSION_CREATED_BY = 'folder.VERSION_CREATED_BY';
+
/** The default string format for model objects of the related table **/
const DEFAULT_STRING_FORMAT = 'YAML';
@@ -89,6 +99,13 @@ abstract class BaseFolderPeer
* @var string
*/
const DEFAULT_LOCALE = 'en_EN';
+ // versionable behavior
+
+ /**
+ * Whether the versioning is enabled
+ */
+ static $isVersioningEnabled = true;
+
/**
* holds an array of fieldnames
*
@@ -96,12 +113,12 @@ abstract class BaseFolderPeer
* e.g. FolderPeer::$fieldNames[FolderPeer::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => 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, )
+ BasePeer::TYPE_PHPNAME => array ('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (FolderPeer::ID, FolderPeer::PARENT, FolderPeer::LINK, FolderPeer::VISIBLE, FolderPeer::POSITION, FolderPeer::CREATED_AT, FolderPeer::UPDATED_AT, FolderPeer::VERSION, FolderPeer::VERSION_CREATED_AT, FolderPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@@ -111,12 +128,12 @@ abstract class BaseFolderPeer
* 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, )
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
+ 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, FolderPeer::VERSION => 7, FolderPeer::VERSION_CREATED_AT => 8, FolderPeer::VERSION_CREATED_BY => 9, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@@ -197,6 +214,9 @@ abstract class BaseFolderPeer
$criteria->addSelectColumn(FolderPeer::POSITION);
$criteria->addSelectColumn(FolderPeer::CREATED_AT);
$criteria->addSelectColumn(FolderPeer::UPDATED_AT);
+ $criteria->addSelectColumn(FolderPeer::VERSION);
+ $criteria->addSelectColumn(FolderPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(FolderPeer::VERSION_CREATED_BY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.PARENT');
@@ -205,6 +225,9 @@ abstract class BaseFolderPeer
$criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
}
}
@@ -419,6 +442,9 @@ abstract class BaseFolderPeer
// Invalidate objects in FolderI18nPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
FolderI18nPeer::clearInstancePool();
+ // Invalidate objects in FolderVersionPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ FolderVersionPeer::clearInstancePool();
}
/**
@@ -812,6 +838,34 @@ abstract class BaseFolderPeer
return $objs;
}
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ public static function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ public static function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ public static function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
} // BaseFolderPeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
diff --git a/core/lib/Thelia/Model/om/BaseFolderQuery.php b/core/lib/Thelia/Model/om/BaseFolderQuery.php
index 6d0dae283..512671886 100644
--- a/core/lib/Thelia/Model/om/BaseFolderQuery.php
+++ b/core/lib/Thelia/Model/om/BaseFolderQuery.php
@@ -18,6 +18,7 @@ use Thelia\Model\Folder;
use Thelia\Model\FolderI18n;
use Thelia\Model\FolderPeer;
use Thelia\Model\FolderQuery;
+use Thelia\Model\FolderVersion;
use Thelia\Model\Image;
use Thelia\Model\Rewriting;
@@ -33,6 +34,9 @@ use Thelia\Model\Rewriting;
* @method FolderQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method FolderQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method FolderQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
+ * @method FolderQuery orderByVersion($order = Criteria::ASC) Order by the version column
+ * @method FolderQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
+ * @method FolderQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
*
* @method FolderQuery groupById() Group by the id column
* @method FolderQuery groupByParent() Group by the parent column
@@ -41,6 +45,9 @@ use Thelia\Model\Rewriting;
* @method FolderQuery groupByPosition() Group by the position column
* @method FolderQuery groupByCreatedAt() Group by the created_at column
* @method FolderQuery groupByUpdatedAt() Group by the updated_at column
+ * @method FolderQuery groupByVersion() Group by the version column
+ * @method FolderQuery groupByVersionCreatedAt() Group by the version_created_at column
+ * @method FolderQuery groupByVersionCreatedBy() Group by the version_created_by column
*
* @method FolderQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method FolderQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -66,6 +73,10 @@ use Thelia\Model\Rewriting;
* @method FolderQuery rightJoinFolderI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FolderI18n relation
* @method FolderQuery innerJoinFolderI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the FolderI18n relation
*
+ * @method FolderQuery leftJoinFolderVersion($relationAlias = null) Adds a LEFT JOIN clause to the query using the FolderVersion relation
+ * @method FolderQuery rightJoinFolderVersion($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FolderVersion relation
+ * @method FolderQuery innerJoinFolderVersion($relationAlias = null) Adds a INNER JOIN clause to the query using the FolderVersion relation
+ *
* @method Folder findOne(PropelPDO $con = null) Return the first Folder matching the query
* @method Folder findOneOrCreate(PropelPDO $con = null) Return the first Folder matching the query, or a new Folder object populated from the query conditions when no match is found
*
@@ -76,6 +87,9 @@ use Thelia\Model\Rewriting;
* @method Folder findOneByPosition(int $position) Return the first Folder filtered by the position column
* @method Folder findOneByCreatedAt(string $created_at) Return the first Folder filtered by the created_at column
* @method Folder findOneByUpdatedAt(string $updated_at) Return the first Folder filtered by the updated_at column
+ * @method Folder findOneByVersion(int $version) Return the first Folder filtered by the version column
+ * @method Folder findOneByVersionCreatedAt(string $version_created_at) Return the first Folder filtered by the version_created_at column
+ * @method Folder findOneByVersionCreatedBy(string $version_created_by) Return the first Folder filtered by the version_created_by column
*
* @method array findById(int $id) Return Folder objects filtered by the id column
* @method array findByParent(int $parent) Return Folder objects filtered by the parent column
@@ -84,6 +98,9 @@ use Thelia\Model\Rewriting;
* @method array findByPosition(int $position) Return Folder objects filtered by the position column
* @method array findByCreatedAt(string $created_at) Return Folder objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return Folder objects filtered by the updated_at column
+ * @method array findByVersion(int $version) Return Folder objects filtered by the version column
+ * @method array findByVersionCreatedAt(string $version_created_at) Return Folder objects filtered by the version_created_at column
+ * @method array findByVersionCreatedBy(string $version_created_by) Return Folder objects filtered by the version_created_by column
*
* @package propel.generator.Thelia.Model.om
*/
@@ -173,7 +190,7 @@ abstract class BaseFolderQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `folder` WHERE `ID` = :p0';
+ $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `folder` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -527,6 +544,119 @@ abstract class BaseFolderQuery extends ModelCriteria
return $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(FolderPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(FolderPeer::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(FolderPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(FolderPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
/**
* Filter the query by a related Image object
*
@@ -897,6 +1027,80 @@ abstract class BaseFolderQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'FolderI18n', '\Thelia\Model\FolderI18nQuery');
}
+ /**
+ * Filter the query by a related FolderVersion object
+ *
+ * @param FolderVersion|PropelObjectCollection $folderVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return FolderQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByFolderVersion($folderVersion, $comparison = null)
+ {
+ if ($folderVersion instanceof FolderVersion) {
+ return $this
+ ->addUsingAlias(FolderPeer::ID, $folderVersion->getId(), $comparison);
+ } elseif ($folderVersion instanceof PropelObjectCollection) {
+ return $this
+ ->useFolderVersionQuery()
+ ->filterByPrimaryKeys($folderVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFolderVersion() only accepts arguments of type FolderVersion or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FolderVersion 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 joinFolderVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FolderVersion');
+
+ // 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, 'FolderVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FolderVersion relation FolderVersion 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\FolderVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFolderVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FolderVersion', '\Thelia\Model\FolderVersionQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseFolderVersion.php b/core/lib/Thelia/Model/om/BaseFolderVersion.php
new file mode 100644
index 000000000..e9ed39e36
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolderVersion.php
@@ -0,0 +1,1482 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseFolderVersion 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 [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);
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return FolderVersion 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[] = FolderVersionPeer::ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return FolderVersion 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[] = FolderVersionPeer::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Set the value of [link] column.
+ *
+ * @param string $v new value
+ * @return FolderVersion 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[] = FolderVersionPeer::LINK;
+ }
+
+
+ return $this;
+ } // setLink()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return FolderVersion 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[] = FolderVersionPeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return FolderVersion 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[] = FolderVersionPeer::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 FolderVersion 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[] = FolderVersionPeer::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 FolderVersion 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[] = FolderVersionPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return FolderVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = FolderVersionPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 FolderVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = FolderVersionPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return FolderVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = FolderVersionPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * 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->version !== 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->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->version = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
+ $this->version_created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->version_created_by = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 10; // 10 = FolderVersionPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating FolderVersion 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->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(FolderVersionPeer::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 = FolderVersionPeer::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(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = FolderVersionQuery::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(FolderVersionPeer::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);
+ FolderVersionPeer::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;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FolderVersionPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::PARENT)) {
+ $modifiedColumns[':p' . $index++] = '`PARENT`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::LINK)) {
+ $modifiedColumns[':p' . $index++] = '`LINK`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(FolderVersionPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `folder_version` (%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;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, 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->aFolder !== null) {
+ if (!$this->aFolder->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = FolderVersionPeer::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 = FolderVersionPeer::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;
+ case 7:
+ return $this->getVersion();
+ break;
+ case 8:
+ return $this->getVersionCreatedAt();
+ break;
+ case 9:
+ return $this->getVersionCreatedBy();
+ 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['FolderVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FolderVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = FolderVersionPeer::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(),
+ $keys[7] => $this->getVersion(),
+ $keys[8] => $this->getVersionCreatedAt(),
+ $keys[9] => $this->getVersionCreatedBy(),
+ );
+ 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 = FolderVersionPeer::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;
+ case 7:
+ $this->setVersion($value);
+ break;
+ case 8:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 9:
+ $this->setVersionCreatedBy($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 = FolderVersionPeer::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]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($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(FolderVersionPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(FolderVersionPeer::ID)) $criteria->add(FolderVersionPeer::ID, $this->id);
+ if ($this->isColumnModified(FolderVersionPeer::PARENT)) $criteria->add(FolderVersionPeer::PARENT, $this->parent);
+ if ($this->isColumnModified(FolderVersionPeer::LINK)) $criteria->add(FolderVersionPeer::LINK, $this->link);
+ if ($this->isColumnModified(FolderVersionPeer::VISIBLE)) $criteria->add(FolderVersionPeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(FolderVersionPeer::POSITION)) $criteria->add(FolderVersionPeer::POSITION, $this->position);
+ if ($this->isColumnModified(FolderVersionPeer::CREATED_AT)) $criteria->add(FolderVersionPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FolderVersionPeer::UPDATED_AT)) $criteria->add(FolderVersionPeer::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(FolderVersionPeer::VERSION)) $criteria->add(FolderVersionPeer::VERSION, $this->version);
+ if ($this->isColumnModified(FolderVersionPeer::VERSION_CREATED_AT)) $criteria->add(FolderVersionPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(FolderVersionPeer::VERSION_CREATED_BY)) $criteria->add(FolderVersionPeer::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(FolderVersionPeer::DATABASE_NAME);
+ $criteria->add(FolderVersionPeer::ID, $this->id);
+ $criteria->add(FolderVersionPeer::VERSION, $this->version);
+
+ 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->getVersion();
+
+ 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->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 FolderVersion (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->setId($this->getId());
+ $copyObj->setParent($this->getParent());
+ $copyObj->setLink($this->getLink());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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 FolderVersion 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 FolderVersionPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new FolderVersionPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Folder object.
+ *
+ * @param Folder $v
+ * @return FolderVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(Folder $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($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->addFolderVersion($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->id !== null)) {
+ $this->aFolder = FolderQuery::create()->findPk($this->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->addFolderVersions($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
+ /**
+ * 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->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = 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->aFolder = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FolderVersionPeer::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/BaseFolderVersionPeer.php b/core/lib/Thelia/Model/om/BaseFolderVersionPeer.php
new file mode 100644
index 000000000..4b61116cd
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolderVersionPeer.php
@@ -0,0 +1,1029 @@
+ array ('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (FolderVersionPeer::ID, FolderVersionPeer::PARENT, FolderVersionPeer::LINK, FolderVersionPeer::VISIBLE, FolderVersionPeer::POSITION, FolderVersionPeer::CREATED_AT, FolderVersionPeer::UPDATED_AT, FolderVersionPeer::VERSION, FolderVersionPeer::VERSION_CREATED_AT, FolderVersionPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ 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. FolderVersionPeer::$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, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
+ BasePeer::TYPE_COLNAME => array (FolderVersionPeer::ID => 0, FolderVersionPeer::PARENT => 1, FolderVersionPeer::LINK => 2, FolderVersionPeer::VISIBLE => 3, FolderVersionPeer::POSITION => 4, FolderVersionPeer::CREATED_AT => 5, FolderVersionPeer::UPDATED_AT => 6, FolderVersionPeer::VERSION => 7, FolderVersionPeer::VERSION_CREATED_AT => 8, FolderVersionPeer::VERSION_CREATED_BY => 9, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 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 = FolderVersionPeer::getFieldNames($toType);
+ $key = isset(FolderVersionPeer::$fieldKeys[$fromType][$name]) ? FolderVersionPeer::$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(FolderVersionPeer::$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, FolderVersionPeer::$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 FolderVersionPeer::$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. FolderVersionPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(FolderVersionPeer::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(FolderVersionPeer::ID);
+ $criteria->addSelectColumn(FolderVersionPeer::PARENT);
+ $criteria->addSelectColumn(FolderVersionPeer::LINK);
+ $criteria->addSelectColumn(FolderVersionPeer::VISIBLE);
+ $criteria->addSelectColumn(FolderVersionPeer::POSITION);
+ $criteria->addSelectColumn(FolderVersionPeer::CREATED_AT);
+ $criteria->addSelectColumn(FolderVersionPeer::UPDATED_AT);
+ $criteria->addSelectColumn(FolderVersionPeer::VERSION);
+ $criteria->addSelectColumn(FolderVersionPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(FolderVersionPeer::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.LINK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * 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(FolderVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FolderVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(FolderVersionPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderVersionPeer::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 FolderVersion
+ * @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 = FolderVersionPeer::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 FolderVersionPeer::populateObjects(FolderVersionPeer::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(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ FolderVersionPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderVersionPeer::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 FolderVersion $obj A FolderVersion 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->getVersion()));
+ } // if key === null
+ FolderVersionPeer::$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 FolderVersion 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 FolderVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+ } 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 FolderVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(FolderVersionPeer::$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 FolderVersion 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(FolderVersionPeer::$instances[$key])) {
+ return FolderVersionPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ FolderVersionPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to folder_version
+ * 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 + 7] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[$startcol], (string) $row[$startcol + 7]));
+ }
+
+ /**
+ * 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 + 7]);
+ }
+
+ /**
+ * 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 = FolderVersionPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = FolderVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = FolderVersionPeer::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;
+ FolderVersionPeer::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 (FolderVersion object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = FolderVersionPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = FolderVersionPeer::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 + FolderVersionPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FolderVersionPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ FolderVersionPeer::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(FolderVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FolderVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FolderVersionPeer::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 FolderVersion 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 FolderVersion 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(FolderVersionPeer::DATABASE_NAME);
+ }
+
+ FolderVersionPeer::addSelectColumns($criteria);
+ $startcol = FolderVersionPeer::NUM_HYDRATE_COLUMNS;
+ FolderPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(FolderVersionPeer::ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FolderVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FolderVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = FolderVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FolderVersionPeer::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 (FolderVersion) to $obj2 (Folder)
+ $obj2->addFolderVersion($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(FolderVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ FolderVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(FolderVersionPeer::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 FolderVersion 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 FolderVersion 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(FolderVersionPeer::DATABASE_NAME);
+ }
+
+ FolderVersionPeer::addSelectColumns($criteria);
+ $startcol2 = FolderVersionPeer::NUM_HYDRATE_COLUMNS;
+
+ FolderPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + FolderPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(FolderVersionPeer::ID, FolderPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = FolderVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = FolderVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = FolderVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ FolderVersionPeer::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 (FolderVersion) to the collection in $obj2 (Folder)
+ $obj2->addFolderVersion($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(FolderVersionPeer::DATABASE_NAME)->getTable(FolderVersionPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseFolderVersionPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseFolderVersionPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new FolderVersionTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return FolderVersionPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FolderVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or FolderVersion 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(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from FolderVersion object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderVersionPeer::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 FolderVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or FolderVersion 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(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(FolderVersionPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(FolderVersionPeer::ID);
+ $value = $criteria->remove(FolderVersionPeer::ID);
+ if ($value) {
+ $selectCriteria->add(FolderVersionPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FolderVersionPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(FolderVersionPeer::VERSION);
+ $value = $criteria->remove(FolderVersionPeer::VERSION);
+ if ($value) {
+ $selectCriteria->add(FolderVersionPeer::VERSION, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(FolderVersionPeer::TABLE_NAME);
+ }
+
+ } else { // $values is FolderVersion object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(FolderVersionPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the folder_version 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(FolderVersionPeer::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(FolderVersionPeer::TABLE_NAME, $con, FolderVersionPeer::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).
+ FolderVersionPeer::clearInstancePool();
+ FolderVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FolderVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FolderVersion 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(FolderVersionPeer::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.
+ FolderVersionPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof FolderVersion) { // it's a model object
+ // invalidate the cache for this single object
+ FolderVersionPeer::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(FolderVersionPeer::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(FolderVersionPeer::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(FolderVersionPeer::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ // we can invalidate the cache for this single PK
+ FolderVersionPeer::removeInstanceFromPool($value);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderVersionPeer::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);
+ FolderVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given FolderVersion 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 FolderVersion $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(FolderVersionPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(FolderVersionPeer::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(FolderVersionPeer::DATABASE_NAME, FolderVersionPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve object using using composite pkey values.
+ * @param int $id
+ * @param int $version
+ * @param PropelPDO $con
+ * @return FolderVersion
+ */
+ public static function retrieveByPK($id, $version, PropelPDO $con = null) {
+ $_instancePoolKey = serialize(array((string) $id, (string) $version));
+ if (null !== ($obj = FolderVersionPeer::getInstanceFromPool($_instancePoolKey))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $criteria = new Criteria(FolderVersionPeer::DATABASE_NAME);
+ $criteria->add(FolderVersionPeer::ID, $id);
+ $criteria->add(FolderVersionPeer::VERSION, $version);
+ $v = FolderVersionPeer::doSelect($criteria, $con);
+
+ return !empty($v) ? $v[0] : null;
+ }
+} // BaseFolderVersionPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseFolderVersionPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php b/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php
new file mode 100644
index 000000000..44e12b519
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php
@@ -0,0 +1,730 @@
+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: [$id, $version]
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return FolderVersion|FolderVersion[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FolderVersionPeer::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(FolderVersionPeer::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 FolderVersion A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `folder_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
+ 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 FolderVersion();
+ $obj->hydrate($row);
+ FolderVersionPeer::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 FolderVersion|FolderVersion[]|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|FolderVersion[]|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 FolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(FolderVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(FolderVersionPeer::VERSION, $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 FolderVersionQuery 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(FolderVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(FolderVersionPeer::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $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
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @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 FolderVersionQuery 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(FolderVersionPeer::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 FolderVersionQuery 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(FolderVersionPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(FolderVersionPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionPeer::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 FolderVersionQuery 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(FolderVersionPeer::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 FolderVersionQuery 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(FolderVersionPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(FolderVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionPeer::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 FolderVersionQuery 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(FolderVersionPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FolderVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionPeer::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 FolderVersionQuery 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(FolderVersionPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FolderVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionPeer::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 FolderVersionQuery 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(FolderVersionPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FolderVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 FolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(FolderVersionPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 FolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(FolderVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(FolderVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 FolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $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 FolderVersionQuery 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(FolderVersionPeer::ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FolderVersionPeer::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 FolderVersionQuery 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 FolderVersion $folderVersion Object to remove from the list of results
+ *
+ * @return FolderVersionQuery The current query, for fluid interface
+ */
+ public function prune($folderVersion = null)
+ {
+ if ($folderVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(FolderVersionPeer::ID), $folderVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(FolderVersionPeer::VERSION), $folderVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseMessage.php b/core/lib/Thelia/Model/om/BaseMessage.php
index 283e188bb..b12e23930 100644
--- a/core/lib/Thelia/Model/om/BaseMessage.php
+++ b/core/lib/Thelia/Model/om/BaseMessage.php
@@ -20,6 +20,9 @@ use Thelia\Model\MessageI18n;
use Thelia\Model\MessageI18nQuery;
use Thelia\Model\MessagePeer;
use Thelia\Model\MessageQuery;
+use Thelia\Model\MessageVersion;
+use Thelia\Model\MessageVersionPeer;
+use Thelia\Model\MessageVersionQuery;
/**
* Base class that represents a row from the 'message' table.
@@ -85,12 +88,37 @@ abstract class BaseMessage extends BaseObject implements Persistent
*/
protected $updated_at;
+ /**
+ * The value for the version field.
+ * Note: this column has a database default value of: 0
+ * @var int
+ */
+ protected $version;
+
+ /**
+ * The value for the version_created_at field.
+ * @var string
+ */
+ protected $version_created_at;
+
+ /**
+ * The value for the version_created_by field.
+ * @var string
+ */
+ protected $version_created_by;
+
/**
* @var PropelObjectCollection|MessageI18n[] Collection to store aggregation of MessageI18n objects.
*/
protected $collMessageI18ns;
protected $collMessageI18nsPartial;
+ /**
+ * @var PropelObjectCollection|MessageVersion[] Collection to store aggregation of MessageVersion objects.
+ */
+ protected $collMessageVersions;
+ protected $collMessageVersionsPartial;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -119,12 +147,47 @@ abstract class BaseMessage extends BaseObject implements Persistent
*/
protected $currentTranslations;
+ // versionable behavior
+
+
+ /**
+ * @var bool
+ */
+ protected $enforceVersion = false;
+
/**
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
*/
protected $messageI18nsScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $messageVersionsScheduledForDeletion = null;
+
+ /**
+ * Applies default values to this object.
+ * This method should be called from the object's constructor (or
+ * equivalent initialization method).
+ * @see __construct()
+ */
+ public function applyDefaultValues()
+ {
+ $this->version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseMessage object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->applyDefaultValues();
+ }
+
/**
* Get the [id] column value.
*
@@ -239,6 +302,63 @@ abstract class BaseMessage extends BaseObject implements Persistent
}
}
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
/**
* Set the value of [id] column.
*
@@ -369,6 +489,71 @@ abstract class BaseMessage extends BaseObject implements Persistent
return $this;
} // setUpdatedAt()
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return Message The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = MessagePeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = MessagePeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return Message The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = MessagePeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -379,6 +564,10 @@ abstract class BaseMessage extends BaseObject implements Persistent
*/
public function hasOnlyDefaultValues()
{
+ if ($this->version !== 0) {
+ return false;
+ }
+
// otherwise, everything was equal, so return true
return true;
} // hasOnlyDefaultValues()
@@ -407,6 +596,9 @@ abstract class BaseMessage extends BaseObject implements Persistent
$this->ref = ($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->version = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
+ $this->version_created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->version_created_by = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->resetModified();
$this->setNew(false);
@@ -415,7 +607,7 @@ abstract class BaseMessage extends BaseObject implements Persistent
$this->ensureConsistency();
}
- return $startcol + 6; // 6 = MessagePeer::NUM_HYDRATE_COLUMNS.
+ return $startcol + 9; // 9 = MessagePeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Message object", $e);
@@ -479,6 +671,8 @@ abstract class BaseMessage extends BaseObject implements Persistent
$this->collMessageI18ns = null;
+ $this->collMessageVersions = null;
+
} // if (deep)
}
@@ -549,6 +743,14 @@ abstract class BaseMessage extends BaseObject implements Persistent
$isInsert = $this->isNew();
try {
$ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
if ($isInsert) {
$ret = $ret && $this->preInsert($con);
// timestampable behavior
@@ -573,6 +775,10 @@ abstract class BaseMessage extends BaseObject implements Persistent
$this->postUpdate($con);
}
$this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
MessagePeer::addInstanceToPool($this);
} else {
$affectedRows = 0;
@@ -631,6 +837,23 @@ abstract class BaseMessage extends BaseObject implements Persistent
}
}
+ if ($this->messageVersionsScheduledForDeletion !== null) {
+ if (!$this->messageVersionsScheduledForDeletion->isEmpty()) {
+ MessageVersionQuery::create()
+ ->filterByPrimaryKeys($this->messageVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->messageVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collMessageVersions !== null) {
+ foreach ($this->collMessageVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -675,6 +898,15 @@ abstract class BaseMessage extends BaseObject implements Persistent
if ($this->isColumnModified(MessagePeer::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
}
+ if ($this->isColumnModified(MessagePeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(MessagePeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
$sql = sprintf(
'INSERT INTO `message` (%s) VALUES (%s)',
@@ -704,6 +936,15 @@ abstract class BaseMessage extends BaseObject implements Persistent
case '`UPDATED_AT`':
$stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
break;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
}
}
$stmt->execute();
@@ -811,6 +1052,14 @@ abstract class BaseMessage extends BaseObject implements Persistent
}
}
+ if ($this->collMessageVersions !== null) {
+ foreach ($this->collMessageVersions as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -864,6 +1113,15 @@ abstract class BaseMessage extends BaseObject implements Persistent
case 5:
return $this->getUpdatedAt();
break;
+ case 6:
+ return $this->getVersion();
+ break;
+ case 7:
+ return $this->getVersionCreatedAt();
+ break;
+ case 8:
+ return $this->getVersionCreatedBy();
+ break;
default:
return null;
break;
@@ -899,11 +1157,17 @@ abstract class BaseMessage extends BaseObject implements Persistent
$keys[3] => $this->getRef(),
$keys[4] => $this->getCreatedAt(),
$keys[5] => $this->getUpdatedAt(),
+ $keys[6] => $this->getVersion(),
+ $keys[7] => $this->getVersionCreatedAt(),
+ $keys[8] => $this->getVersionCreatedBy(),
);
if ($includeForeignObjects) {
if (null !== $this->collMessageI18ns) {
$result['MessageI18ns'] = $this->collMessageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
+ if (null !== $this->collMessageVersions) {
+ $result['MessageVersions'] = $this->collMessageVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
}
return $result;
@@ -956,6 +1220,15 @@ abstract class BaseMessage extends BaseObject implements Persistent
case 5:
$this->setUpdatedAt($value);
break;
+ case 6:
+ $this->setVersion($value);
+ break;
+ case 7:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 8:
+ $this->setVersionCreatedBy($value);
+ break;
} // switch()
}
@@ -986,6 +1259,9 @@ abstract class BaseMessage extends BaseObject implements Persistent
if (array_key_exists($keys[3], $arr)) $this->setRef($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]]);
+ if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($arr[$keys[8]]);
}
/**
@@ -1003,6 +1279,9 @@ abstract class BaseMessage extends BaseObject implements Persistent
if ($this->isColumnModified(MessagePeer::REF)) $criteria->add(MessagePeer::REF, $this->ref);
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);
+ if ($this->isColumnModified(MessagePeer::VERSION)) $criteria->add(MessagePeer::VERSION, $this->version);
+ if ($this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) $criteria->add(MessagePeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(MessagePeer::VERSION_CREATED_BY)) $criteria->add(MessagePeer::VERSION_CREATED_BY, $this->version_created_by);
return $criteria;
}
@@ -1071,6 +1350,9 @@ abstract class BaseMessage extends BaseObject implements Persistent
$copyObj->setRef($this->getRef());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@@ -1085,6 +1367,12 @@ abstract class BaseMessage extends BaseObject implements Persistent
}
}
+ foreach ($this->getMessageVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addMessageVersion($relObj->copy($deepCopy));
+ }
+ }
+
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1149,6 +1437,9 @@ abstract class BaseMessage extends BaseObject implements Persistent
if ('MessageI18n' == $relationName) {
$this->initMessageI18ns();
}
+ if ('MessageVersion' == $relationName) {
+ $this->initMessageVersions();
+ }
}
/**
@@ -1362,6 +1653,213 @@ abstract class BaseMessage extends BaseObject implements Persistent
}
}
+ /**
+ * Clears out the collMessageVersions 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 addMessageVersions()
+ */
+ public function clearMessageVersions()
+ {
+ $this->collMessageVersions = null; // important to set this to null since that means it is uninitialized
+ $this->collMessageVersionsPartial = null;
+ }
+
+ /**
+ * reset is the collMessageVersions collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialMessageVersions($v = true)
+ {
+ $this->collMessageVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collMessageVersions collection.
+ *
+ * By default this just sets the collMessageVersions collection to an empty array (like clearcollMessageVersions());
+ * 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 initMessageVersions($overrideExisting = true)
+ {
+ if (null !== $this->collMessageVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collMessageVersions = new PropelObjectCollection();
+ $this->collMessageVersions->setModel('MessageVersion');
+ }
+
+ /**
+ * Gets an array of MessageVersion 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|MessageVersion[] List of MessageVersion objects
+ * @throws PropelException
+ */
+ public function getMessageVersions($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collMessageVersionsPartial && !$this->isNew();
+ if (null === $this->collMessageVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collMessageVersions) {
+ // return empty collection
+ $this->initMessageVersions();
+ } else {
+ $collMessageVersions = MessageVersionQuery::create(null, $criteria)
+ ->filterByMessage($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collMessageVersionsPartial && count($collMessageVersions)) {
+ $this->initMessageVersions(false);
+
+ foreach($collMessageVersions as $obj) {
+ if (false == $this->collMessageVersions->contains($obj)) {
+ $this->collMessageVersions->append($obj);
+ }
+ }
+
+ $this->collMessageVersionsPartial = true;
+ }
+
+ return $collMessageVersions;
+ }
+
+ if($partial && $this->collMessageVersions) {
+ foreach($this->collMessageVersions as $obj) {
+ if($obj->isNew()) {
+ $collMessageVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collMessageVersions = $collMessageVersions;
+ $this->collMessageVersionsPartial = false;
+ }
+ }
+
+ return $this->collMessageVersions;
+ }
+
+ /**
+ * Sets a collection of MessageVersion 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 $messageVersions A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setMessageVersions(PropelCollection $messageVersions, PropelPDO $con = null)
+ {
+ $this->messageVersionsScheduledForDeletion = $this->getMessageVersions(new Criteria(), $con)->diff($messageVersions);
+
+ foreach ($this->messageVersionsScheduledForDeletion as $messageVersionRemoved) {
+ $messageVersionRemoved->setMessage(null);
+ }
+
+ $this->collMessageVersions = null;
+ foreach ($messageVersions as $messageVersion) {
+ $this->addMessageVersion($messageVersion);
+ }
+
+ $this->collMessageVersions = $messageVersions;
+ $this->collMessageVersionsPartial = false;
+ }
+
+ /**
+ * Returns the number of related MessageVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related MessageVersion objects.
+ * @throws PropelException
+ */
+ public function countMessageVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collMessageVersionsPartial && !$this->isNew();
+ if (null === $this->collMessageVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collMessageVersions) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getMessageVersions());
+ }
+ $query = MessageVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByMessage($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collMessageVersions);
+ }
+ }
+
+ /**
+ * Method called to associate a MessageVersion object to this object
+ * through the MessageVersion foreign key attribute.
+ *
+ * @param MessageVersion $l MessageVersion
+ * @return Message The current object (for fluent API support)
+ */
+ public function addMessageVersion(MessageVersion $l)
+ {
+ if ($this->collMessageVersions === null) {
+ $this->initMessageVersions();
+ $this->collMessageVersionsPartial = true;
+ }
+ if (!$this->collMessageVersions->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddMessageVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param MessageVersion $messageVersion The messageVersion object to add.
+ */
+ protected function doAddMessageVersion($messageVersion)
+ {
+ $this->collMessageVersions[]= $messageVersion;
+ $messageVersion->setMessage($this);
+ }
+
+ /**
+ * @param MessageVersion $messageVersion The messageVersion object to remove.
+ */
+ public function removeMessageVersion($messageVersion)
+ {
+ if ($this->getMessageVersions()->contains($messageVersion)) {
+ $this->collMessageVersions->remove($this->collMessageVersions->search($messageVersion));
+ if (null === $this->messageVersionsScheduledForDeletion) {
+ $this->messageVersionsScheduledForDeletion = clone $this->collMessageVersions;
+ $this->messageVersionsScheduledForDeletion->clear();
+ }
+ $this->messageVersionsScheduledForDeletion[]= $messageVersion;
+ $messageVersion->setMessage(null);
+ }
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1373,9 +1871,13 @@ abstract class BaseMessage extends BaseObject implements Persistent
$this->ref = null;
$this->created_at = null;
$this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
+ $this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
@@ -1398,6 +1900,11 @@ abstract class BaseMessage extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
+ if ($this->collMessageVersions) {
+ foreach ($this->collMessageVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
// i18n behavior
@@ -1408,6 +1915,10 @@ abstract class BaseMessage extends BaseObject implements Persistent
$this->collMessageI18ns->clearIterator();
}
$this->collMessageI18ns = null;
+ if ($this->collMessageVersions instanceof PropelCollection) {
+ $this->collMessageVersions->clearIterator();
+ }
+ $this->collMessageVersions = null;
}
/**
@@ -1615,4 +2126,295 @@ abstract class BaseMessage extends BaseObject implements Persistent
return $this;
}
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return Message
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @param PropelPDO $con An optional PropelPDO connection to use.
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (MessagePeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return MessageVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new MessageVersion();
+ $version->setId($this->getId());
+ $version->setCode($this->getCode());
+ $version->setSecured($this->getSecured());
+ $version->setRef($this->getRef());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setMessage($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return Message The current object (for fluent API support)
+ * @throws PropelException - if no object with the given version can be found.
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No Message object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param MessageVersion $version The version object to use
+ * @param PropelPDO $con the connection to use
+ * @param array $loadedObjects objects thats been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return Message The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+
+ $loadedObjects['Message'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setCode($version->getCode());
+ $this->setSecured($version->getSecured());
+ $this->setRef($version->getRef());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = MessageVersionQuery::create()
+ ->filterByMessage($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return MessageVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return MessageVersionQuery::create()
+ ->filterByMessage($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return PropelObjectCollection A list of MessageVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(MessageVersionPeer::VERSION);
+
+ return $this->getMessageVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($this->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param integer $number the number of record to return.
+ * @param MessageVersionQuery|Criteria $criteria Additional criteria to filter.
+ * @param PropelPDO $con An optional connection to use.
+ *
+ * @return PropelCollection|MessageVersion[] List of MessageVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
+ {
+ $criteria = MessageVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(MessageVersionPeer::VERSION);
+ $criteria->limit($number);
+
+ return $this->getMessageVersions($criteria, $con);
+ }
}
diff --git a/core/lib/Thelia/Model/om/BaseMessagePeer.php b/core/lib/Thelia/Model/om/BaseMessagePeer.php
index a2ccf2403..487e319ae 100644
--- a/core/lib/Thelia/Model/om/BaseMessagePeer.php
+++ b/core/lib/Thelia/Model/om/BaseMessagePeer.php
@@ -12,6 +12,7 @@ use \PropelPDO;
use Thelia\Model\Message;
use Thelia\Model\MessageI18nPeer;
use Thelia\Model\MessagePeer;
+use Thelia\Model\MessageVersionPeer;
use Thelia\Model\map\MessageTableMap;
/**
@@ -37,13 +38,13 @@ abstract class BaseMessagePeer
const TM_CLASS = 'MessageTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 6;
+ const NUM_COLUMNS = 9;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
- const NUM_HYDRATE_COLUMNS = 6;
+ const NUM_HYDRATE_COLUMNS = 9;
/** the column name for the ID field */
const ID = 'message.ID';
@@ -63,6 +64,15 @@ abstract class BaseMessagePeer
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'message.UPDATED_AT';
+ /** the column name for the VERSION field */
+ const VERSION = 'message.VERSION';
+
+ /** the column name for the VERSION_CREATED_AT field */
+ const VERSION_CREATED_AT = 'message.VERSION_CREATED_AT';
+
+ /** the column name for the VERSION_CREATED_BY field */
+ const VERSION_CREATED_BY = 'message.VERSION_CREATED_BY';
+
/** The default string format for model objects of the related table **/
const DEFAULT_STRING_FORMAT = 'YAML';
@@ -82,6 +92,13 @@ abstract class BaseMessagePeer
* @var string
*/
const DEFAULT_LOCALE = 'en_EN';
+ // versionable behavior
+
+ /**
+ * Whether the versioning is enabled
+ */
+ static $isVersioningEnabled = true;
+
/**
* holds an array of fieldnames
*
@@ -89,12 +106,12 @@ abstract class BaseMessagePeer
* e.g. MessagePeer::$fieldNames[MessagePeer::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => array ('Id', 'Code', 'Secured', 'Ref', 'CreatedAt', 'UpdatedAt', ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'secured', 'ref', 'createdAt', 'updatedAt', ),
- BasePeer::TYPE_COLNAME => array (MessagePeer::ID, MessagePeer::CODE, MessagePeer::SECURED, MessagePeer::REF, MessagePeer::CREATED_AT, MessagePeer::UPDATED_AT, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'SECURED', 'REF', 'CREATED_AT', 'UPDATED_AT', ),
- BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'secured', 'ref', 'created_at', 'updated_at', ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ BasePeer::TYPE_PHPNAME => array ('Id', 'Code', 'Secured', 'Ref', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'secured', 'ref', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (MessagePeer::ID, MessagePeer::CODE, MessagePeer::SECURED, MessagePeer::REF, MessagePeer::CREATED_AT, MessagePeer::UPDATED_AT, MessagePeer::VERSION, MessagePeer::VERSION_CREATED_AT, MessagePeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'SECURED', 'REF', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'secured', 'ref', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@@ -104,12 +121,12 @@ abstract class BaseMessagePeer
* e.g. MessagePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Secured' => 2, 'Ref' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
- BasePeer::TYPE_COLNAME => array (MessagePeer::ID => 0, MessagePeer::CODE => 1, MessagePeer::SECURED => 2, MessagePeer::REF => 3, MessagePeer::CREATED_AT => 4, MessagePeer::UPDATED_AT => 5, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'SECURED' => 2, 'REF' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
- BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'created_at' => 4, 'updated_at' => 5, ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Secured' => 2, 'Ref' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ),
+ BasePeer::TYPE_COLNAME => array (MessagePeer::ID => 0, MessagePeer::CODE => 1, MessagePeer::SECURED => 2, MessagePeer::REF => 3, MessagePeer::CREATED_AT => 4, MessagePeer::UPDATED_AT => 5, MessagePeer::VERSION => 6, MessagePeer::VERSION_CREATED_AT => 7, MessagePeer::VERSION_CREATED_BY => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'SECURED' => 2, 'REF' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, 'VERSION' => 6, 'VERSION_CREATED_AT' => 7, 'VERSION_CREATED_BY' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'created_at' => 4, 'updated_at' => 5, 'version' => 6, 'version_created_at' => 7, 'version_created_by' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@@ -189,6 +206,9 @@ abstract class BaseMessagePeer
$criteria->addSelectColumn(MessagePeer::REF);
$criteria->addSelectColumn(MessagePeer::CREATED_AT);
$criteria->addSelectColumn(MessagePeer::UPDATED_AT);
+ $criteria->addSelectColumn(MessagePeer::VERSION);
+ $criteria->addSelectColumn(MessagePeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(MessagePeer::VERSION_CREATED_BY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CODE');
@@ -196,6 +216,9 @@ abstract class BaseMessagePeer
$criteria->addSelectColumn($alias . '.REF');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
}
}
@@ -398,6 +421,9 @@ abstract class BaseMessagePeer
// Invalidate objects in MessageI18nPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
MessageI18nPeer::clearInstancePool();
+ // Invalidate objects in MessageVersionPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ MessageVersionPeer::clearInstancePool();
}
/**
@@ -791,6 +817,34 @@ abstract class BaseMessagePeer
return $objs;
}
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ public static function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ public static function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ public static function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
} // BaseMessagePeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
diff --git a/core/lib/Thelia/Model/om/BaseMessageQuery.php b/core/lib/Thelia/Model/om/BaseMessageQuery.php
index 691c71f6e..119544645 100644
--- a/core/lib/Thelia/Model/om/BaseMessageQuery.php
+++ b/core/lib/Thelia/Model/om/BaseMessageQuery.php
@@ -16,6 +16,7 @@ use Thelia\Model\Message;
use Thelia\Model\MessageI18n;
use Thelia\Model\MessagePeer;
use Thelia\Model\MessageQuery;
+use Thelia\Model\MessageVersion;
/**
* Base class that represents a query for the 'message' table.
@@ -28,6 +29,9 @@ use Thelia\Model\MessageQuery;
* @method MessageQuery orderByRef($order = Criteria::ASC) Order by the ref column
* @method MessageQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method MessageQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
+ * @method MessageQuery orderByVersion($order = Criteria::ASC) Order by the version column
+ * @method MessageQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
+ * @method MessageQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
*
* @method MessageQuery groupById() Group by the id column
* @method MessageQuery groupByCode() Group by the code column
@@ -35,6 +39,9 @@ use Thelia\Model\MessageQuery;
* @method MessageQuery groupByRef() Group by the ref column
* @method MessageQuery groupByCreatedAt() Group by the created_at column
* @method MessageQuery groupByUpdatedAt() Group by the updated_at column
+ * @method MessageQuery groupByVersion() Group by the version column
+ * @method MessageQuery groupByVersionCreatedAt() Group by the version_created_at column
+ * @method MessageQuery groupByVersionCreatedBy() Group by the version_created_by column
*
* @method MessageQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method MessageQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -44,6 +51,10 @@ use Thelia\Model\MessageQuery;
* @method MessageQuery rightJoinMessageI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the MessageI18n relation
* @method MessageQuery innerJoinMessageI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the MessageI18n relation
*
+ * @method MessageQuery leftJoinMessageVersion($relationAlias = null) Adds a LEFT JOIN clause to the query using the MessageVersion relation
+ * @method MessageQuery rightJoinMessageVersion($relationAlias = null) Adds a RIGHT JOIN clause to the query using the MessageVersion relation
+ * @method MessageQuery innerJoinMessageVersion($relationAlias = null) Adds a INNER JOIN clause to the query using the MessageVersion relation
+ *
* @method Message findOne(PropelPDO $con = null) Return the first Message matching the query
* @method Message findOneOrCreate(PropelPDO $con = null) Return the first Message matching the query, or a new Message object populated from the query conditions when no match is found
*
@@ -53,6 +64,9 @@ use Thelia\Model\MessageQuery;
* @method Message findOneByRef(string $ref) Return the first Message filtered by the ref column
* @method Message findOneByCreatedAt(string $created_at) Return the first Message filtered by the created_at column
* @method Message findOneByUpdatedAt(string $updated_at) Return the first Message filtered by the updated_at column
+ * @method Message findOneByVersion(int $version) Return the first Message filtered by the version column
+ * @method Message findOneByVersionCreatedAt(string $version_created_at) Return the first Message filtered by the version_created_at column
+ * @method Message findOneByVersionCreatedBy(string $version_created_by) Return the first Message filtered by the version_created_by column
*
* @method array findById(int $id) Return Message objects filtered by the id column
* @method array findByCode(string $code) Return Message objects filtered by the code column
@@ -60,6 +74,9 @@ use Thelia\Model\MessageQuery;
* @method array findByRef(string $ref) Return Message objects filtered by the ref column
* @method array findByCreatedAt(string $created_at) Return Message objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return Message objects filtered by the updated_at column
+ * @method array findByVersion(int $version) Return Message objects filtered by the version column
+ * @method array findByVersionCreatedAt(string $version_created_at) Return Message objects filtered by the version_created_at column
+ * @method array findByVersionCreatedBy(string $version_created_by) Return Message objects filtered by the version_created_by column
*
* @package propel.generator.Thelia.Model.om
*/
@@ -149,7 +166,7 @@ abstract class BaseMessageQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT `ID`, `CODE`, `SECURED`, `REF`, `CREATED_AT`, `UPDATED_AT` FROM `message` WHERE `ID` = :p0';
+ $sql = 'SELECT `ID`, `CODE`, `SECURED`, `REF`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `message` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -450,6 +467,119 @@ abstract class BaseMessageQuery extends ModelCriteria
return $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(MessagePeer::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(MessagePeer::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessagePeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(MessagePeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(MessagePeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessagePeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessagePeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
/**
* Filter the query by a related MessageI18n object
*
@@ -524,6 +654,80 @@ abstract class BaseMessageQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'MessageI18n', '\Thelia\Model\MessageI18nQuery');
}
+ /**
+ * Filter the query by a related MessageVersion object
+ *
+ * @param MessageVersion|PropelObjectCollection $messageVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByMessageVersion($messageVersion, $comparison = null)
+ {
+ if ($messageVersion instanceof MessageVersion) {
+ return $this
+ ->addUsingAlias(MessagePeer::ID, $messageVersion->getId(), $comparison);
+ } elseif ($messageVersion instanceof PropelObjectCollection) {
+ return $this
+ ->useMessageVersionQuery()
+ ->filterByPrimaryKeys($messageVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByMessageVersion() only accepts arguments of type MessageVersion or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the MessageVersion 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 joinMessageVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('MessageVersion');
+
+ // 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, 'MessageVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the MessageVersion relation MessageVersion 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\MessageVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useMessageVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinMessageVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'MessageVersion', '\Thelia\Model\MessageVersionQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseMessageVersion.php b/core/lib/Thelia/Model/om/BaseMessageVersion.php
new file mode 100644
index 000000000..c09212cef
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessageVersion.php
@@ -0,0 +1,1427 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseMessageVersion 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 [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Get the [secured] column value.
+ *
+ * @return int
+ */
+ public function getSecured()
+ {
+ return $this->secured;
+ }
+
+ /**
+ * 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);
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return MessageVersion 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[] = MessageVersionPeer::ID;
+ }
+
+ if ($this->aMessage !== null && $this->aMessage->getId() !== $v) {
+ $this->aMessage = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return MessageVersion 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[] = MessageVersionPeer::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [secured] column.
+ *
+ * @param int $v new value
+ * @return MessageVersion The current object (for fluent API support)
+ */
+ public function setSecured($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->secured !== $v) {
+ $this->secured = $v;
+ $this->modifiedColumns[] = MessageVersionPeer::SECURED;
+ }
+
+
+ return $this;
+ } // setSecured()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return MessageVersion 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[] = MessageVersionPeer::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 MessageVersion 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[] = MessageVersionPeer::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 MessageVersion 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[] = MessageVersionPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return MessageVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = MessageVersionPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 MessageVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = MessageVersionPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return MessageVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = MessageVersionPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * 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->version !== 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->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->secured = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
+ $this->ref = ($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->version = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
+ $this->version_created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->version_created_by = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = MessageVersionPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating MessageVersion 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->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(MessageVersionPeer::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 = MessageVersionPeer::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(MessageVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = MessageVersionQuery::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(MessageVersionPeer::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);
+ MessageVersionPeer::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;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(MessageVersionPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(MessageVersionPeer::CODE)) {
+ $modifiedColumns[':p' . $index++] = '`CODE`';
+ }
+ if ($this->isColumnModified(MessageVersionPeer::SECURED)) {
+ $modifiedColumns[':p' . $index++] = '`SECURED`';
+ }
+ if ($this->isColumnModified(MessageVersionPeer::REF)) {
+ $modifiedColumns[':p' . $index++] = '`REF`';
+ }
+ if ($this->isColumnModified(MessageVersionPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(MessageVersionPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+ if ($this->isColumnModified(MessageVersionPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(MessageVersionPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(MessageVersionPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `message_version` (%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 '`SECURED`':
+ $stmt->bindValue($identifier, $this->secured, 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;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, 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->aMessage !== null) {
+ if (!$this->aMessage->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aMessage->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = MessageVersionPeer::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 = MessageVersionPeer::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->getSecured();
+ break;
+ case 3:
+ return $this->getRef();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ case 6:
+ return $this->getVersion();
+ break;
+ case 7:
+ return $this->getVersionCreatedAt();
+ break;
+ case 8:
+ return $this->getVersionCreatedBy();
+ 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['MessageVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['MessageVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = MessageVersionPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getSecured(),
+ $keys[3] => $this->getRef(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ $keys[6] => $this->getVersion(),
+ $keys[7] => $this->getVersionCreatedAt(),
+ $keys[8] => $this->getVersionCreatedBy(),
+ );
+ 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 = MessageVersionPeer::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->setSecured($value);
+ break;
+ case 3:
+ $this->setRef($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ case 6:
+ $this->setVersion($value);
+ break;
+ case 7:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 8:
+ $this->setVersionCreatedBy($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 = MessageVersionPeer::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->setSecured($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setRef($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]]);
+ if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($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(MessageVersionPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(MessageVersionPeer::ID)) $criteria->add(MessageVersionPeer::ID, $this->id);
+ if ($this->isColumnModified(MessageVersionPeer::CODE)) $criteria->add(MessageVersionPeer::CODE, $this->code);
+ if ($this->isColumnModified(MessageVersionPeer::SECURED)) $criteria->add(MessageVersionPeer::SECURED, $this->secured);
+ if ($this->isColumnModified(MessageVersionPeer::REF)) $criteria->add(MessageVersionPeer::REF, $this->ref);
+ if ($this->isColumnModified(MessageVersionPeer::CREATED_AT)) $criteria->add(MessageVersionPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(MessageVersionPeer::UPDATED_AT)) $criteria->add(MessageVersionPeer::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(MessageVersionPeer::VERSION)) $criteria->add(MessageVersionPeer::VERSION, $this->version);
+ if ($this->isColumnModified(MessageVersionPeer::VERSION_CREATED_AT)) $criteria->add(MessageVersionPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(MessageVersionPeer::VERSION_CREATED_BY)) $criteria->add(MessageVersionPeer::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(MessageVersionPeer::DATABASE_NAME);
+ $criteria->add(MessageVersionPeer::ID, $this->id);
+ $criteria->add(MessageVersionPeer::VERSION, $this->version);
+
+ 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->getVersion();
+
+ 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->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 MessageVersion (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->setId($this->getId());
+ $copyObj->setCode($this->getCode());
+ $copyObj->setSecured($this->getSecured());
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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 MessageVersion 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 MessageVersionPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new MessageVersionPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Message object.
+ *
+ * @param Message $v
+ * @return MessageVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setMessage(Message $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($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->addMessageVersion($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->id !== null)) {
+ $this->aMessage = MessageQuery::create()->findPk($this->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->addMessageVersions($this);
+ */
+ }
+
+ return $this->aMessage;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->secured = null;
+ $this->ref = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = 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->aMessage = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(MessageVersionPeer::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/BaseMessageVersionPeer.php b/core/lib/Thelia/Model/om/BaseMessageVersionPeer.php
new file mode 100644
index 000000000..714607ebe
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessageVersionPeer.php
@@ -0,0 +1,1024 @@
+ array ('Id', 'Code', 'Secured', 'Ref', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'secured', 'ref', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (MessageVersionPeer::ID, MessageVersionPeer::CODE, MessageVersionPeer::SECURED, MessageVersionPeer::REF, MessageVersionPeer::CREATED_AT, MessageVersionPeer::UPDATED_AT, MessageVersionPeer::VERSION, MessageVersionPeer::VERSION_CREATED_AT, MessageVersionPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'SECURED', 'REF', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'secured', 'ref', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ 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. MessageVersionPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Secured' => 2, 'Ref' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ),
+ BasePeer::TYPE_COLNAME => array (MessageVersionPeer::ID => 0, MessageVersionPeer::CODE => 1, MessageVersionPeer::SECURED => 2, MessageVersionPeer::REF => 3, MessageVersionPeer::CREATED_AT => 4, MessageVersionPeer::UPDATED_AT => 5, MessageVersionPeer::VERSION => 6, MessageVersionPeer::VERSION_CREATED_AT => 7, MessageVersionPeer::VERSION_CREATED_BY => 8, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'SECURED' => 2, 'REF' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, 'VERSION' => 6, 'VERSION_CREATED_AT' => 7, 'VERSION_CREATED_BY' => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'created_at' => 4, 'updated_at' => 5, 'version' => 6, 'version_created_at' => 7, 'version_created_by' => 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 = MessageVersionPeer::getFieldNames($toType);
+ $key = isset(MessageVersionPeer::$fieldKeys[$fromType][$name]) ? MessageVersionPeer::$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(MessageVersionPeer::$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, MessageVersionPeer::$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 MessageVersionPeer::$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. MessageVersionPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(MessageVersionPeer::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(MessageVersionPeer::ID);
+ $criteria->addSelectColumn(MessageVersionPeer::CODE);
+ $criteria->addSelectColumn(MessageVersionPeer::SECURED);
+ $criteria->addSelectColumn(MessageVersionPeer::REF);
+ $criteria->addSelectColumn(MessageVersionPeer::CREATED_AT);
+ $criteria->addSelectColumn(MessageVersionPeer::UPDATED_AT);
+ $criteria->addSelectColumn(MessageVersionPeer::VERSION);
+ $criteria->addSelectColumn(MessageVersionPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(MessageVersionPeer::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.SECURED');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * 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(MessageVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ MessageVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(MessageVersionPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageVersionPeer::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 MessageVersion
+ * @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 = MessageVersionPeer::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 MessageVersionPeer::populateObjects(MessageVersionPeer::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(MessageVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ MessageVersionPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageVersionPeer::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 MessageVersion $obj A MessageVersion 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->getVersion()));
+ } // if key === null
+ MessageVersionPeer::$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 MessageVersion 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 MessageVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+ } 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 MessageVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(MessageVersionPeer::$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 MessageVersion 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(MessageVersionPeer::$instances[$key])) {
+ return MessageVersionPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ MessageVersionPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to message_version
+ * 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 + 6] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[$startcol], (string) $row[$startcol + 6]));
+ }
+
+ /**
+ * 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 + 6]);
+ }
+
+ /**
+ * 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 = MessageVersionPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = MessageVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = MessageVersionPeer::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;
+ MessageVersionPeer::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 (MessageVersion object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = MessageVersionPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = MessageVersionPeer::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 + MessageVersionPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = MessageVersionPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ MessageVersionPeer::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(MessageVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ MessageVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(MessageVersionPeer::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 MessageVersion 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 MessageVersion 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(MessageVersionPeer::DATABASE_NAME);
+ }
+
+ MessageVersionPeer::addSelectColumns($criteria);
+ $startcol = MessageVersionPeer::NUM_HYDRATE_COLUMNS;
+ MessagePeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(MessageVersionPeer::ID, MessagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = MessageVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = MessageVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = MessageVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ MessageVersionPeer::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 (MessageVersion) to $obj2 (Message)
+ $obj2->addMessageVersion($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(MessageVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ MessageVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(MessageVersionPeer::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 MessageVersion 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 MessageVersion 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(MessageVersionPeer::DATABASE_NAME);
+ }
+
+ MessageVersionPeer::addSelectColumns($criteria);
+ $startcol2 = MessageVersionPeer::NUM_HYDRATE_COLUMNS;
+
+ MessagePeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + MessagePeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(MessageVersionPeer::ID, MessagePeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = MessageVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = MessageVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = MessageVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ MessageVersionPeer::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 (MessageVersion) to the collection in $obj2 (Message)
+ $obj2->addMessageVersion($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(MessageVersionPeer::DATABASE_NAME)->getTable(MessageVersionPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseMessageVersionPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseMessageVersionPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new MessageVersionTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return MessageVersionPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a MessageVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or MessageVersion 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(MessageVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from MessageVersion object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageVersionPeer::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 MessageVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or MessageVersion 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(MessageVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(MessageVersionPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(MessageVersionPeer::ID);
+ $value = $criteria->remove(MessageVersionPeer::ID);
+ if ($value) {
+ $selectCriteria->add(MessageVersionPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(MessageVersionPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(MessageVersionPeer::VERSION);
+ $value = $criteria->remove(MessageVersionPeer::VERSION);
+ if ($value) {
+ $selectCriteria->add(MessageVersionPeer::VERSION, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(MessageVersionPeer::TABLE_NAME);
+ }
+
+ } else { // $values is MessageVersion object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(MessageVersionPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the message_version 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(MessageVersionPeer::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(MessageVersionPeer::TABLE_NAME, $con, MessageVersionPeer::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).
+ MessageVersionPeer::clearInstancePool();
+ MessageVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a MessageVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or MessageVersion 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(MessageVersionPeer::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.
+ MessageVersionPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof MessageVersion) { // it's a model object
+ // invalidate the cache for this single object
+ MessageVersionPeer::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(MessageVersionPeer::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(MessageVersionPeer::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(MessageVersionPeer::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ // we can invalidate the cache for this single PK
+ MessageVersionPeer::removeInstanceFromPool($value);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageVersionPeer::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);
+ MessageVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given MessageVersion 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 MessageVersion $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(MessageVersionPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(MessageVersionPeer::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(MessageVersionPeer::DATABASE_NAME, MessageVersionPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve object using using composite pkey values.
+ * @param int $id
+ * @param int $version
+ * @param PropelPDO $con
+ * @return MessageVersion
+ */
+ public static function retrieveByPK($id, $version, PropelPDO $con = null) {
+ $_instancePoolKey = serialize(array((string) $id, (string) $version));
+ if (null !== ($obj = MessageVersionPeer::getInstanceFromPool($_instancePoolKey))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(MessageVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $criteria = new Criteria(MessageVersionPeer::DATABASE_NAME);
+ $criteria->add(MessageVersionPeer::ID, $id);
+ $criteria->add(MessageVersionPeer::VERSION, $version);
+ $v = MessageVersionPeer::doSelect($criteria, $con);
+
+ return !empty($v) ? $v[0] : null;
+ }
+} // BaseMessageVersionPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseMessageVersionPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php b/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php
new file mode 100644
index 000000000..19660e740
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php
@@ -0,0 +1,673 @@
+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: [$id, $version]
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return MessageVersion|MessageVersion[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = MessageVersionPeer::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(MessageVersionPeer::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 MessageVersion A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `CODE`, `SECURED`, `REF`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `message_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
+ 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 MessageVersion();
+ $obj->hydrate($row);
+ MessageVersionPeer::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 MessageVersion|MessageVersion[]|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|MessageVersion[]|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 MessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(MessageVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(MessageVersionPeer::VERSION, $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 MessageVersionQuery 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(MessageVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(MessageVersionPeer::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $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
+ *
+ *
+ * @see filterByMessage()
+ *
+ * @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 MessageVersionQuery 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(MessageVersionPeer::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 MessageVersionQuery 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(MessageVersionPeer::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the secured column
+ *
+ * Example usage:
+ *
+ * $query->filterBySecured(1234); // WHERE secured = 1234
+ * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34)
+ * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12
+ *
+ *
+ * @param mixed $secured The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return MessageVersionQuery The current query, for fluid interface
+ */
+ public function filterBySecured($secured = null, $comparison = null)
+ {
+ if (is_array($secured)) {
+ $useMinMax = false;
+ if (isset($secured['min'])) {
+ $this->addUsingAlias(MessageVersionPeer::SECURED, $secured['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($secured['max'])) {
+ $this->addUsingAlias(MessageVersionPeer::SECURED, $secured['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionPeer::SECURED, $secured, $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 MessageVersionQuery 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(MessageVersionPeer::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 MessageVersionQuery 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(MessageVersionPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(MessageVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionPeer::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 MessageVersionQuery 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(MessageVersionPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(MessageVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 MessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(MessageVersionPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 MessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(MessageVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(MessageVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 MessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $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 MessageVersionQuery 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(MessageVersionPeer::ID, $message->getId(), $comparison);
+ } elseif ($message instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(MessageVersionPeer::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 MessageVersionQuery 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 MessageVersion $messageVersion Object to remove from the list of results
+ *
+ * @return MessageVersionQuery The current query, for fluid interface
+ */
+ public function prune($messageVersion = null)
+ {
+ if ($messageVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(MessageVersionPeer::ID), $messageVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(MessageVersionPeer::VERSION), $messageVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/core/lib/Thelia/Model/om/BaseProduct.php b/core/lib/Thelia/Model/om/BaseProduct.php
index 539c798d8..dee173dbd 100644
--- a/core/lib/Thelia/Model/om/BaseProduct.php
+++ b/core/lib/Thelia/Model/om/BaseProduct.php
@@ -32,6 +32,9 @@ use Thelia\Model\ProductI18n;
use Thelia\Model\ProductI18nQuery;
use Thelia\Model\ProductPeer;
use Thelia\Model\ProductQuery;
+use Thelia\Model\ProductVersion;
+use Thelia\Model\ProductVersionPeer;
+use Thelia\Model\ProductVersionQuery;
use Thelia\Model\Rewriting;
use Thelia\Model\RewritingQuery;
use Thelia\Model\Stock;
@@ -155,6 +158,25 @@ abstract class BaseProduct extends BaseObject implements Persistent
*/
protected $updated_at;
+ /**
+ * The value for the version field.
+ * Note: this column has a database default value of: 0
+ * @var int
+ */
+ protected $version;
+
+ /**
+ * The value for the version_created_at field.
+ * @var string
+ */
+ protected $version_created_at;
+
+ /**
+ * The value for the version_created_by field.
+ * @var string
+ */
+ protected $version_created_by;
+
/**
* @var TaxRule
*/
@@ -220,6 +242,12 @@ abstract class BaseProduct extends BaseObject implements Persistent
protected $collProductI18ns;
protected $collProductI18nsPartial;
+ /**
+ * @var PropelObjectCollection|ProductVersion[] Collection to store aggregation of ProductVersion objects.
+ */
+ protected $collProductVersions;
+ protected $collProductVersionsPartial;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -248,6 +276,14 @@ abstract class BaseProduct extends BaseObject implements Persistent
*/
protected $currentTranslations;
+ // versionable behavior
+
+
+ /**
+ * @var bool
+ */
+ protected $enforceVersion = false;
+
/**
* An array of objects scheduled for deletion.
* @var PropelObjectCollection
@@ -308,6 +344,12 @@ abstract class BaseProduct extends BaseObject implements Persistent
*/
protected $productI18nsScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $productVersionsScheduledForDeletion = null;
+
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
@@ -320,6 +362,7 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->promo = 0;
$this->stock = 0;
$this->visible = 0;
+ $this->version = 0;
}
/**
@@ -526,6 +569,63 @@ abstract class BaseProduct extends BaseObject implements Persistent
}
}
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
/**
* Set the value of [id] column.
*
@@ -828,6 +928,71 @@ abstract class BaseProduct extends BaseObject implements Persistent
return $this;
} // setUpdatedAt()
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = ProductPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = ProductPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return Product The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = ProductPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -854,6 +1019,10 @@ abstract class BaseProduct extends BaseObject implements Persistent
return false;
}
+ if ($this->version !== 0) {
+ return false;
+ }
+
// otherwise, everything was equal, so return true
return true;
} // hasOnlyDefaultValues()
@@ -890,6 +1059,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
$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->version = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null;
+ $this->version_created_at = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
+ $this->version_created_by = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
$this->resetModified();
$this->setNew(false);
@@ -898,7 +1070,7 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->ensureConsistency();
}
- return $startcol + 14; // 14 = ProductPeer::NUM_HYDRATE_COLUMNS.
+ return $startcol + 17; // 17 = ProductPeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Product object", $e);
@@ -984,6 +1156,8 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->collProductI18ns = null;
+ $this->collProductVersions = null;
+
} // if (deep)
}
@@ -1054,6 +1228,14 @@ abstract class BaseProduct extends BaseObject implements Persistent
$isInsert = $this->isNew();
try {
$ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
if ($isInsert) {
$ret = $ret && $this->preInsert($con);
// timestampable behavior
@@ -1078,6 +1260,10 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->postUpdate($con);
}
$this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
ProductPeer::addInstanceToPool($this);
} else {
$affectedRows = 0;
@@ -1305,6 +1491,23 @@ abstract class BaseProduct extends BaseObject implements Persistent
}
}
+ if ($this->productVersionsScheduledForDeletion !== null) {
+ if (!$this->productVersionsScheduledForDeletion->isEmpty()) {
+ ProductVersionQuery::create()
+ ->filterByPrimaryKeys($this->productVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->productVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collProductVersions !== null) {
+ foreach ($this->collProductVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -1373,6 +1576,15 @@ abstract class BaseProduct extends BaseObject implements Persistent
if ($this->isColumnModified(ProductPeer::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
}
+ if ($this->isColumnModified(ProductPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(ProductPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
$sql = sprintf(
'INSERT INTO `product` (%s) VALUES (%s)',
@@ -1426,6 +1638,15 @@ abstract class BaseProduct extends BaseObject implements Persistent
case '`UPDATED_AT`':
$stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
break;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
}
}
$stmt->execute();
@@ -1617,6 +1838,14 @@ abstract class BaseProduct extends BaseObject implements Persistent
}
}
+ if ($this->collProductVersions !== null) {
+ foreach ($this->collProductVersions as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -1694,6 +1923,15 @@ abstract class BaseProduct extends BaseObject implements Persistent
case 13:
return $this->getUpdatedAt();
break;
+ case 14:
+ return $this->getVersion();
+ break;
+ case 15:
+ return $this->getVersionCreatedAt();
+ break;
+ case 16:
+ return $this->getVersionCreatedBy();
+ break;
default:
return null;
break;
@@ -1737,6 +1975,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
$keys[11] => $this->getPosition(),
$keys[12] => $this->getCreatedAt(),
$keys[13] => $this->getUpdatedAt(),
+ $keys[14] => $this->getVersion(),
+ $keys[15] => $this->getVersionCreatedAt(),
+ $keys[16] => $this->getVersionCreatedBy(),
);
if ($includeForeignObjects) {
if (null !== $this->aTaxRule) {
@@ -1772,6 +2013,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
if (null !== $this->collProductI18ns) {
$result['ProductI18ns'] = $this->collProductI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
+ if (null !== $this->collProductVersions) {
+ $result['ProductVersions'] = $this->collProductVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
}
return $result;
@@ -1848,6 +2092,15 @@ abstract class BaseProduct extends BaseObject implements Persistent
case 13:
$this->setUpdatedAt($value);
break;
+ case 14:
+ $this->setVersion($value);
+ break;
+ case 15:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 16:
+ $this->setVersionCreatedBy($value);
+ break;
} // switch()
}
@@ -1886,6 +2139,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
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]]);
+ if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setVersionCreatedAt($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setVersionCreatedBy($arr[$keys[16]]);
}
/**
@@ -1911,6 +2167,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
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);
+ if ($this->isColumnModified(ProductPeer::VERSION)) $criteria->add(ProductPeer::VERSION, $this->version);
+ if ($this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) $criteria->add(ProductPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(ProductPeer::VERSION_CREATED_BY)) $criteria->add(ProductPeer::VERSION_CREATED_BY, $this->version_created_by);
return $criteria;
}
@@ -1987,6 +2246,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
$copyObj->setPosition($this->getPosition());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@@ -2055,6 +2317,12 @@ abstract class BaseProduct extends BaseObject implements Persistent
}
}
+ foreach ($this->getProductVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProductVersion($relObj->copy($deepCopy));
+ }
+ }
+
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -2197,6 +2465,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
if ('ProductI18n' == $relationName) {
$this->initProductI18ns();
}
+ if ('ProductVersion' == $relationName) {
+ $this->initProductVersions();
+ }
}
/**
@@ -4648,6 +4919,213 @@ abstract class BaseProduct extends BaseObject implements Persistent
}
}
+ /**
+ * Clears out the collProductVersions 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 addProductVersions()
+ */
+ public function clearProductVersions()
+ {
+ $this->collProductVersions = null; // important to set this to null since that means it is uninitialized
+ $this->collProductVersionsPartial = null;
+ }
+
+ /**
+ * reset is the collProductVersions collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialProductVersions($v = true)
+ {
+ $this->collProductVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collProductVersions collection.
+ *
+ * By default this just sets the collProductVersions collection to an empty array (like clearcollProductVersions());
+ * 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 initProductVersions($overrideExisting = true)
+ {
+ if (null !== $this->collProductVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collProductVersions = new PropelObjectCollection();
+ $this->collProductVersions->setModel('ProductVersion');
+ }
+
+ /**
+ * Gets an array of ProductVersion 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|ProductVersion[] List of ProductVersion objects
+ * @throws PropelException
+ */
+ public function getProductVersions($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collProductVersionsPartial && !$this->isNew();
+ if (null === $this->collProductVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductVersions) {
+ // return empty collection
+ $this->initProductVersions();
+ } else {
+ $collProductVersions = ProductVersionQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collProductVersionsPartial && count($collProductVersions)) {
+ $this->initProductVersions(false);
+
+ foreach($collProductVersions as $obj) {
+ if (false == $this->collProductVersions->contains($obj)) {
+ $this->collProductVersions->append($obj);
+ }
+ }
+
+ $this->collProductVersionsPartial = true;
+ }
+
+ return $collProductVersions;
+ }
+
+ if($partial && $this->collProductVersions) {
+ foreach($this->collProductVersions as $obj) {
+ if($obj->isNew()) {
+ $collProductVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collProductVersions = $collProductVersions;
+ $this->collProductVersionsPartial = false;
+ }
+ }
+
+ return $this->collProductVersions;
+ }
+
+ /**
+ * Sets a collection of ProductVersion 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 $productVersions A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function setProductVersions(PropelCollection $productVersions, PropelPDO $con = null)
+ {
+ $this->productVersionsScheduledForDeletion = $this->getProductVersions(new Criteria(), $con)->diff($productVersions);
+
+ foreach ($this->productVersionsScheduledForDeletion as $productVersionRemoved) {
+ $productVersionRemoved->setProduct(null);
+ }
+
+ $this->collProductVersions = null;
+ foreach ($productVersions as $productVersion) {
+ $this->addProductVersion($productVersion);
+ }
+
+ $this->collProductVersions = $productVersions;
+ $this->collProductVersionsPartial = false;
+ }
+
+ /**
+ * Returns the number of related ProductVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ProductVersion objects.
+ * @throws PropelException
+ */
+ public function countProductVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collProductVersionsPartial && !$this->isNew();
+ if (null === $this->collProductVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductVersions) {
+ return 0;
+ } else {
+ if($partial && !$criteria) {
+ return count($this->getProductVersions());
+ }
+ $query = ProductVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collProductVersions);
+ }
+ }
+
+ /**
+ * Method called to associate a ProductVersion object to this object
+ * through the ProductVersion foreign key attribute.
+ *
+ * @param ProductVersion $l ProductVersion
+ * @return Product The current object (for fluent API support)
+ */
+ public function addProductVersion(ProductVersion $l)
+ {
+ if ($this->collProductVersions === null) {
+ $this->initProductVersions();
+ $this->collProductVersionsPartial = true;
+ }
+ if (!$this->collProductVersions->contains($l)) { // only add it if the **same** object is not already associated
+ $this->doAddProductVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ProductVersion $productVersion The productVersion object to add.
+ */
+ protected function doAddProductVersion($productVersion)
+ {
+ $this->collProductVersions[]= $productVersion;
+ $productVersion->setProduct($this);
+ }
+
+ /**
+ * @param ProductVersion $productVersion The productVersion object to remove.
+ */
+ public function removeProductVersion($productVersion)
+ {
+ if ($this->getProductVersions()->contains($productVersion)) {
+ $this->collProductVersions->remove($this->collProductVersions->search($productVersion));
+ if (null === $this->productVersionsScheduledForDeletion) {
+ $this->productVersionsScheduledForDeletion = clone $this->collProductVersions;
+ $this->productVersionsScheduledForDeletion->clear();
+ }
+ $this->productVersionsScheduledForDeletion[]= $productVersion;
+ $productVersion->setProduct(null);
+ }
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -4667,6 +5145,9 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->position = null;
$this->created_at = null;
$this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
@@ -4738,6 +5219,11 @@ abstract class BaseProduct extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
+ if ($this->collProductVersions) {
+ foreach ($this->collProductVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
// i18n behavior
@@ -4784,6 +5270,10 @@ abstract class BaseProduct extends BaseObject implements Persistent
$this->collProductI18ns->clearIterator();
}
$this->collProductI18ns = null;
+ if ($this->collProductVersions instanceof PropelCollection) {
+ $this->collProductVersions->clearIterator();
+ }
+ $this->collProductVersions = null;
$this->aTaxRule = null;
}
@@ -5016,4 +5506,311 @@ abstract class BaseProduct extends BaseObject implements Persistent
return $this;
}
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return Product
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @param PropelPDO $con An optional PropelPDO connection to use.
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (ProductPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return ProductVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new ProductVersion();
+ $version->setId($this->getId());
+ $version->setTaxRuleId($this->getTaxRuleId());
+ $version->setRef($this->getRef());
+ $version->setPrice($this->getPrice());
+ $version->setPrice2($this->getPrice2());
+ $version->setEcotax($this->getEcotax());
+ $version->setNewness($this->getNewness());
+ $version->setPromo($this->getPromo());
+ $version->setStock($this->getStock());
+ $version->setVisible($this->getVisible());
+ $version->setWeight($this->getWeight());
+ $version->setPosition($this->getPosition());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setProduct($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return Product The current object (for fluent API support)
+ * @throws PropelException - if no object with the given version can be found.
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No Product object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the curent object to the value they had at a specific version
+ *
+ * @param ProductVersion $version The version object to use
+ * @param PropelPDO $con the connection to use
+ * @param array $loadedObjects objects thats been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return Product The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+
+ $loadedObjects['Product'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setTaxRuleId($version->getTaxRuleId());
+ $this->setRef($version->getRef());
+ $this->setPrice($version->getPrice());
+ $this->setPrice2($version->getPrice2());
+ $this->setEcotax($version->getEcotax());
+ $this->setNewness($version->getNewness());
+ $this->setPromo($version->getPromo());
+ $this->setStock($version->getStock());
+ $this->setVisible($version->getVisible());
+ $this->setWeight($version->getWeight());
+ $this->setPosition($version->getPosition());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = ProductVersionQuery::create()
+ ->filterByProduct($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param PropelPDO $con the connection to use
+ *
+ * @return ProductVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return ProductVersionQuery::create()
+ ->filterByProduct($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param PropelPDO $con the connection to use
+ *
+ * @return PropelObjectCollection A list of ProductVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(ProductVersionPeer::VERSION);
+
+ return $this->getProductVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param PropelPDO $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($this->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param integer $number the number of record to return.
+ * @param ProductVersionQuery|Criteria $criteria Additional criteria to filter.
+ * @param PropelPDO $con An optional connection to use.
+ *
+ * @return PropelCollection|ProductVersion[] List of ProductVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
+ {
+ $criteria = ProductVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(ProductVersionPeer::VERSION);
+ $criteria->limit($number);
+
+ return $this->getProductVersions($criteria, $con);
+ }
}
diff --git a/core/lib/Thelia/Model/om/BaseProductPeer.php b/core/lib/Thelia/Model/om/BaseProductPeer.php
index c81cfb9fa..abb0863f3 100644
--- a/core/lib/Thelia/Model/om/BaseProductPeer.php
+++ b/core/lib/Thelia/Model/om/BaseProductPeer.php
@@ -18,6 +18,7 @@ use Thelia\Model\Product;
use Thelia\Model\ProductCategoryPeer;
use Thelia\Model\ProductI18nPeer;
use Thelia\Model\ProductPeer;
+use Thelia\Model\ProductVersionPeer;
use Thelia\Model\RewritingPeer;
use Thelia\Model\StockPeer;
use Thelia\Model\TaxRulePeer;
@@ -46,13 +47,13 @@ abstract class BaseProductPeer
const TM_CLASS = 'ProductTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 14;
+ const NUM_COLUMNS = 17;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
- const NUM_HYDRATE_COLUMNS = 14;
+ const NUM_HYDRATE_COLUMNS = 17;
/** the column name for the ID field */
const ID = 'product.ID';
@@ -96,6 +97,15 @@ abstract class BaseProductPeer
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'product.UPDATED_AT';
+ /** the column name for the VERSION field */
+ const VERSION = 'product.VERSION';
+
+ /** the column name for the VERSION_CREATED_AT field */
+ const VERSION_CREATED_AT = 'product.VERSION_CREATED_AT';
+
+ /** the column name for the VERSION_CREATED_BY field */
+ const VERSION_CREATED_BY = 'product.VERSION_CREATED_BY';
+
/** The default string format for model objects of the related table **/
const DEFAULT_STRING_FORMAT = 'YAML';
@@ -115,6 +125,13 @@ abstract class BaseProductPeer
* @var string
*/
const DEFAULT_LOCALE = 'en_EN';
+ // versionable behavior
+
+ /**
+ * Whether the versioning is enabled
+ */
+ static $isVersioningEnabled = true;
+
/**
* holds an array of fieldnames
*
@@ -122,12 +139,12 @@ abstract class BaseProductPeer
* e.g. ProductPeer::$fieldNames[ProductPeer::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => array ('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Stock', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'stock', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', ),
- BasePeer::TYPE_COLNAME => array (ProductPeer::ID, ProductPeer::TAX_RULE_ID, ProductPeer::REF, ProductPeer::PRICE, ProductPeer::PRICE2, ProductPeer::ECOTAX, ProductPeer::NEWNESS, ProductPeer::PROMO, ProductPeer::STOCK, ProductPeer::VISIBLE, ProductPeer::WEIGHT, ProductPeer::POSITION, ProductPeer::CREATED_AT, ProductPeer::UPDATED_AT, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'REF', 'PRICE', 'PRICE2', 'ECOTAX', 'NEWNESS', 'PROMO', 'STOCK', 'VISIBLE', 'WEIGHT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
- BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'stock', 'visible', 'weight', 'position', 'created_at', 'updated_at', ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
+ BasePeer::TYPE_PHPNAME => array ('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Stock', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'stock', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (ProductPeer::ID, ProductPeer::TAX_RULE_ID, ProductPeer::REF, ProductPeer::PRICE, ProductPeer::PRICE2, ProductPeer::ECOTAX, ProductPeer::NEWNESS, ProductPeer::PROMO, ProductPeer::STOCK, ProductPeer::VISIBLE, ProductPeer::WEIGHT, ProductPeer::POSITION, ProductPeer::CREATED_AT, ProductPeer::UPDATED_AT, ProductPeer::VERSION, ProductPeer::VERSION_CREATED_AT, ProductPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'REF', 'PRICE', 'PRICE2', 'ECOTAX', 'NEWNESS', 'PROMO', 'STOCK', 'VISIBLE', 'WEIGHT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'stock', 'visible', 'weight', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
);
/**
@@ -137,12 +154,12 @@ abstract class BaseProductPeer
* e.g. ProductPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Price' => 3, 'Price2' => 4, 'Ecotax' => 5, 'Newness' => 6, 'Promo' => 7, 'Stock' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'stock' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'createdAt' => 12, 'updatedAt' => 13, ),
- BasePeer::TYPE_COLNAME => array (ProductPeer::ID => 0, ProductPeer::TAX_RULE_ID => 1, ProductPeer::REF => 2, ProductPeer::PRICE => 3, ProductPeer::PRICE2 => 4, ProductPeer::ECOTAX => 5, ProductPeer::NEWNESS => 6, ProductPeer::PROMO => 7, ProductPeer::STOCK => 8, ProductPeer::VISIBLE => 9, ProductPeer::WEIGHT => 10, ProductPeer::POSITION => 11, ProductPeer::CREATED_AT => 12, ProductPeer::UPDATED_AT => 13, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'PRICE' => 3, 'PRICE2' => 4, 'ECOTAX' => 5, 'NEWNESS' => 6, 'PROMO' => 7, 'STOCK' => 8, 'VISIBLE' => 9, 'WEIGHT' => 10, 'POSITION' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ),
- BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'stock' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'created_at' => 12, 'updated_at' => 13, ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Price' => 3, 'Price2' => 4, 'Ecotax' => 5, 'Newness' => 6, 'Promo' => 7, 'Stock' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, 'VersionCreatedAt' => 15, 'VersionCreatedBy' => 16, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'stock' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, 'versionCreatedAt' => 15, 'versionCreatedBy' => 16, ),
+ BasePeer::TYPE_COLNAME => array (ProductPeer::ID => 0, ProductPeer::TAX_RULE_ID => 1, ProductPeer::REF => 2, ProductPeer::PRICE => 3, ProductPeer::PRICE2 => 4, ProductPeer::ECOTAX => 5, ProductPeer::NEWNESS => 6, ProductPeer::PROMO => 7, ProductPeer::STOCK => 8, ProductPeer::VISIBLE => 9, ProductPeer::WEIGHT => 10, ProductPeer::POSITION => 11, ProductPeer::CREATED_AT => 12, ProductPeer::UPDATED_AT => 13, ProductPeer::VERSION => 14, ProductPeer::VERSION_CREATED_AT => 15, ProductPeer::VERSION_CREATED_BY => 16, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'PRICE' => 3, 'PRICE2' => 4, 'ECOTAX' => 5, 'NEWNESS' => 6, 'PROMO' => 7, 'STOCK' => 8, 'VISIBLE' => 9, 'WEIGHT' => 10, 'POSITION' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, 'VERSION_CREATED_AT' => 15, 'VERSION_CREATED_BY' => 16, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'stock' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, 'version_created_at' => 15, 'version_created_by' => 16, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
);
/**
@@ -230,6 +247,9 @@ abstract class BaseProductPeer
$criteria->addSelectColumn(ProductPeer::POSITION);
$criteria->addSelectColumn(ProductPeer::CREATED_AT);
$criteria->addSelectColumn(ProductPeer::UPDATED_AT);
+ $criteria->addSelectColumn(ProductPeer::VERSION);
+ $criteria->addSelectColumn(ProductPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(ProductPeer::VERSION_CREATED_BY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.TAX_RULE_ID');
@@ -245,6 +265,9 @@ abstract class BaseProductPeer
$criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
}
}
@@ -474,6 +497,9 @@ abstract class BaseProductPeer
// Invalidate objects in ProductI18nPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
ProductI18nPeer::clearInstancePool();
+ // Invalidate objects in ProductVersionPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ProductVersionPeer::clearInstancePool();
}
/**
@@ -1105,6 +1131,34 @@ abstract class BaseProductPeer
return $objs;
}
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ public static function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ public static function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ public static function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
} // BaseProductPeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
diff --git a/core/lib/Thelia/Model/om/BaseProductQuery.php b/core/lib/Thelia/Model/om/BaseProductQuery.php
index 337de1c7e..95c9db6e6 100644
--- a/core/lib/Thelia/Model/om/BaseProductQuery.php
+++ b/core/lib/Thelia/Model/om/BaseProductQuery.php
@@ -22,6 +22,7 @@ use Thelia\Model\ProductCategory;
use Thelia\Model\ProductI18n;
use Thelia\Model\ProductPeer;
use Thelia\Model\ProductQuery;
+use Thelia\Model\ProductVersion;
use Thelia\Model\Rewriting;
use Thelia\Model\Stock;
use Thelia\Model\TaxRule;
@@ -45,6 +46,9 @@ use Thelia\Model\TaxRule;
* @method ProductQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
+ * @method ProductQuery orderByVersion($order = Criteria::ASC) Order by the version column
+ * @method ProductQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
+ * @method ProductQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
*
* @method ProductQuery groupById() Group by the id column
* @method ProductQuery groupByTaxRuleId() Group by the tax_rule_id column
@@ -60,6 +64,9 @@ use Thelia\Model\TaxRule;
* @method ProductQuery groupByPosition() Group by the position column
* @method ProductQuery groupByCreatedAt() Group by the created_at column
* @method ProductQuery groupByUpdatedAt() Group by the updated_at column
+ * @method ProductQuery groupByVersion() Group by the version column
+ * @method ProductQuery groupByVersionCreatedAt() Group by the version_created_at column
+ * @method ProductQuery groupByVersionCreatedBy() Group by the version_created_by column
*
* @method ProductQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ProductQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -109,6 +116,10 @@ use Thelia\Model\TaxRule;
* @method ProductQuery rightJoinProductI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductI18n relation
* @method ProductQuery innerJoinProductI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductI18n relation
*
+ * @method ProductQuery leftJoinProductVersion($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductVersion relation
+ * @method ProductQuery rightJoinProductVersion($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductVersion relation
+ * @method ProductQuery innerJoinProductVersion($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductVersion relation
+ *
* @method Product findOne(PropelPDO $con = null) Return the first Product matching the query
* @method Product findOneOrCreate(PropelPDO $con = null) Return the first Product matching the query, or a new Product object populated from the query conditions when no match is found
*
@@ -126,6 +137,9 @@ use Thelia\Model\TaxRule;
* @method Product findOneByPosition(int $position) Return the first Product filtered by the position column
* @method Product findOneByCreatedAt(string $created_at) Return the first Product filtered by the created_at column
* @method Product findOneByUpdatedAt(string $updated_at) Return the first Product filtered by the updated_at column
+ * @method Product findOneByVersion(int $version) Return the first Product filtered by the version column
+ * @method Product findOneByVersionCreatedAt(string $version_created_at) Return the first Product filtered by the version_created_at column
+ * @method Product findOneByVersionCreatedBy(string $version_created_by) Return the first Product filtered by the version_created_by column
*
* @method array findById(int $id) Return Product objects filtered by the id column
* @method array findByTaxRuleId(int $tax_rule_id) Return Product objects filtered by the tax_rule_id column
@@ -141,6 +155,9 @@ use Thelia\Model\TaxRule;
* @method array findByPosition(int $position) Return Product objects filtered by the position column
* @method array findByCreatedAt(string $created_at) Return Product objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return Product objects filtered by the updated_at column
+ * @method array findByVersion(int $version) Return Product objects filtered by the version column
+ * @method array findByVersionCreatedAt(string $version_created_at) Return Product objects filtered by the version_created_at column
+ * @method array findByVersionCreatedBy(string $version_created_by) Return Product objects filtered by the version_created_by column
*
* @package propel.generator.Thelia.Model.om
*/
@@ -230,7 +247,7 @@ abstract class BaseProductQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `PRICE`, `PRICE2`, `ECOTAX`, `NEWNESS`, `PROMO`, `STOCK`, `VISIBLE`, `WEIGHT`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `product` WHERE `ID` = :p0';
+ $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `PRICE`, `PRICE2`, `ECOTAX`, `NEWNESS`, `PROMO`, `STOCK`, `VISIBLE`, `WEIGHT`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -873,6 +890,119 @@ abstract class BaseProductQuery extends ModelCriteria
return $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt, $comparison);
}
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(ProductPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(ProductPeer::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(ProductPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(ProductPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
/**
* Filter the query by a related TaxRule object
*
@@ -1689,6 +1819,80 @@ abstract class BaseProductQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'ProductI18n', '\Thelia\Model\ProductI18nQuery');
}
+ /**
+ * Filter the query by a related ProductVersion object
+ *
+ * @param ProductVersion|PropelObjectCollection $productVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByProductVersion($productVersion, $comparison = null)
+ {
+ if ($productVersion instanceof ProductVersion) {
+ return $this
+ ->addUsingAlias(ProductPeer::ID, $productVersion->getId(), $comparison);
+ } elseif ($productVersion instanceof PropelObjectCollection) {
+ return $this
+ ->useProductVersionQuery()
+ ->filterByPrimaryKeys($productVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProductVersion() only accepts arguments of type ProductVersion or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductVersion 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 joinProductVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductVersion');
+
+ // 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, 'ProductVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductVersion relation ProductVersion 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\ProductVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useProductVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductVersion', '\Thelia\Model\ProductVersionQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/om/BaseProductVersion.php b/core/lib/Thelia/Model/om/BaseProductVersion.php
new file mode 100644
index 000000000..c38608f34
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductVersion.php
@@ -0,0 +1,1891 @@
+newness = 0;
+ $this->promo = 0;
+ $this->stock = 0;
+ $this->visible = 0;
+ $this->version = 0;
+ }
+
+ /**
+ * Initializes internal state of BaseProductVersion 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 [stock] column value.
+ *
+ * @return int
+ */
+ public function getStock()
+ {
+ return $this->stock;
+ }
+
+ /**
+ * 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);
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_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 getVersionCreatedAt($format = 'Y-m-d H:i:s')
+ {
+ if ($this->version_created_at === null) {
+ return null;
+ }
+
+ if ($this->version_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->version_created_at);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
+ }
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ } elseif (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ } else {
+ return $dt->format($format);
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [tax_rule_id] column.
+ *
+ * @param int $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::TAX_RULE_ID;
+ }
+
+
+ return $this;
+ } // setTaxRuleId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [price] column.
+ *
+ * @param double $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::PRICE;
+ }
+
+
+ return $this;
+ } // setPrice()
+
+ /**
+ * Set the value of [price2] column.
+ *
+ * @param double $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::PRICE2;
+ }
+
+
+ return $this;
+ } // setPrice2()
+
+ /**
+ * Set the value of [ecotax] column.
+ *
+ * @param double $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::ECOTAX;
+ }
+
+
+ return $this;
+ } // setEcotax()
+
+ /**
+ * Set the value of [newness] column.
+ *
+ * @param int $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::NEWNESS;
+ }
+
+
+ return $this;
+ } // setNewness()
+
+ /**
+ * Set the value of [promo] column.
+ *
+ * @param int $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::PROMO;
+ }
+
+
+ return $this;
+ } // setPromo()
+
+ /**
+ * Set the value of [stock] column.
+ *
+ * @param int $v new value
+ * @return ProductVersion The current object (for fluent API support)
+ */
+ public function setStock($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->stock !== $v) {
+ $this->stock = $v;
+ $this->modifiedColumns[] = ProductVersionPeer::STOCK;
+ }
+
+
+ return $this;
+ } // setStock()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [weight] column.
+ *
+ * @param double $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::WEIGHT;
+ }
+
+
+ return $this;
+ } // setWeight()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return ProductVersion 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[] = ProductVersionPeer::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 ProductVersion 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[] = ProductVersionPeer::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 ProductVersion 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[] = ProductVersionPeer::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return ProductVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = ProductVersionPeer::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_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 ProductVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_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->version_created_at = $newDateAsString;
+ $this->modifiedColumns[] = ProductVersionPeer::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return ProductVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = ProductVersionPeer::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * 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->stock !== 0) {
+ return false;
+ }
+
+ if ($this->visible !== 0) {
+ return false;
+ }
+
+ if ($this->version !== 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->stock = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
+ $this->visible = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
+ $this->weight = ($row[$startcol + 10] !== null) ? (double) $row[$startcol + 10] : null;
+ $this->position = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
+ $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->version = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null;
+ $this->version_created_at = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
+ $this->version_created_by = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 17; // 17 = ProductVersionPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ProductVersion 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->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(ProductVersionPeer::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 = ProductVersionPeer::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(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ProductVersionQuery::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(ProductVersionPeer::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);
+ ProductVersionPeer::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;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ProductVersionPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::TAX_RULE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::REF)) {
+ $modifiedColumns[':p' . $index++] = '`REF`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::PRICE)) {
+ $modifiedColumns[':p' . $index++] = '`PRICE`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::PRICE2)) {
+ $modifiedColumns[':p' . $index++] = '`PRICE2`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::ECOTAX)) {
+ $modifiedColumns[':p' . $index++] = '`ECOTAX`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::NEWNESS)) {
+ $modifiedColumns[':p' . $index++] = '`NEWNESS`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::PROMO)) {
+ $modifiedColumns[':p' . $index++] = '`PROMO`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::STOCK)) {
+ $modifiedColumns[':p' . $index++] = '`STOCK`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = '`VISIBLE`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::WEIGHT)) {
+ $modifiedColumns[':p' . $index++] = '`WEIGHT`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::POSITION)) {
+ $modifiedColumns[':p' . $index++] = '`POSITION`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::VERSION)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
+ }
+ if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `product_version` (%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 '`STOCK`':
+ $stmt->bindValue($identifier, $this->stock, 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;
+ case '`VERSION`':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case '`VERSION_CREATED_AT`':
+ $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
+ break;
+ case '`VERSION_CREATED_BY`':
+ $stmt->bindValue($identifier, $this->version_created_by, 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 (($retval = ProductVersionPeer::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 = ProductVersionPeer::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->getStock();
+ 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;
+ case 14:
+ return $this->getVersion();
+ break;
+ case 15:
+ return $this->getVersionCreatedAt();
+ break;
+ case 16:
+ return $this->getVersionCreatedBy();
+ 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['ProductVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ProductVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = ProductVersionPeer::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->getStock(),
+ $keys[9] => $this->getVisible(),
+ $keys[10] => $this->getWeight(),
+ $keys[11] => $this->getPosition(),
+ $keys[12] => $this->getCreatedAt(),
+ $keys[13] => $this->getUpdatedAt(),
+ $keys[14] => $this->getVersion(),
+ $keys[15] => $this->getVersionCreatedAt(),
+ $keys[16] => $this->getVersionCreatedBy(),
+ );
+ 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 = ProductVersionPeer::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->setStock($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;
+ case 14:
+ $this->setVersion($value);
+ break;
+ case 15:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 16:
+ $this->setVersionCreatedBy($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 = ProductVersionPeer::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->setStock($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setVersionCreatedAt($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setVersionCreatedBy($arr[$keys[16]]);
+ }
+
+ /**
+ * 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(ProductVersionPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ProductVersionPeer::ID)) $criteria->add(ProductVersionPeer::ID, $this->id);
+ if ($this->isColumnModified(ProductVersionPeer::TAX_RULE_ID)) $criteria->add(ProductVersionPeer::TAX_RULE_ID, $this->tax_rule_id);
+ if ($this->isColumnModified(ProductVersionPeer::REF)) $criteria->add(ProductVersionPeer::REF, $this->ref);
+ if ($this->isColumnModified(ProductVersionPeer::PRICE)) $criteria->add(ProductVersionPeer::PRICE, $this->price);
+ if ($this->isColumnModified(ProductVersionPeer::PRICE2)) $criteria->add(ProductVersionPeer::PRICE2, $this->price2);
+ if ($this->isColumnModified(ProductVersionPeer::ECOTAX)) $criteria->add(ProductVersionPeer::ECOTAX, $this->ecotax);
+ if ($this->isColumnModified(ProductVersionPeer::NEWNESS)) $criteria->add(ProductVersionPeer::NEWNESS, $this->newness);
+ if ($this->isColumnModified(ProductVersionPeer::PROMO)) $criteria->add(ProductVersionPeer::PROMO, $this->promo);
+ if ($this->isColumnModified(ProductVersionPeer::STOCK)) $criteria->add(ProductVersionPeer::STOCK, $this->stock);
+ if ($this->isColumnModified(ProductVersionPeer::VISIBLE)) $criteria->add(ProductVersionPeer::VISIBLE, $this->visible);
+ if ($this->isColumnModified(ProductVersionPeer::WEIGHT)) $criteria->add(ProductVersionPeer::WEIGHT, $this->weight);
+ if ($this->isColumnModified(ProductVersionPeer::POSITION)) $criteria->add(ProductVersionPeer::POSITION, $this->position);
+ if ($this->isColumnModified(ProductVersionPeer::CREATED_AT)) $criteria->add(ProductVersionPeer::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ProductVersionPeer::UPDATED_AT)) $criteria->add(ProductVersionPeer::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(ProductVersionPeer::VERSION)) $criteria->add(ProductVersionPeer::VERSION, $this->version);
+ if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_AT)) $criteria->add(ProductVersionPeer::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_BY)) $criteria->add(ProductVersionPeer::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(ProductVersionPeer::DATABASE_NAME);
+ $criteria->add(ProductVersionPeer::ID, $this->id);
+ $criteria->add(ProductVersionPeer::VERSION, $this->version);
+
+ 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->getVersion();
+
+ 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->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 ProductVersion (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->setId($this->getId());
+ $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->setStock($this->getStock());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setWeight($this->getWeight());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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 ProductVersion 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 ProductVersionPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ProductVersionPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a Product object.
+ *
+ * @param Product $v
+ * @return ProductVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(Product $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($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->addProductVersion($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->id !== null)) {
+ $this->aProduct = ProductQuery::create()->findPk($this->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->addProductVersions($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * 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->stock = null;
+ $this->visible = null;
+ $this->weight = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = 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->aProduct = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ProductVersionPeer::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/BaseProductVersionPeer.php b/core/lib/Thelia/Model/om/BaseProductVersionPeer.php
new file mode 100644
index 000000000..c6da88329
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductVersionPeer.php
@@ -0,0 +1,1064 @@
+ array ('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Stock', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'stock', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ BasePeer::TYPE_COLNAME => array (ProductVersionPeer::ID, ProductVersionPeer::TAX_RULE_ID, ProductVersionPeer::REF, ProductVersionPeer::PRICE, ProductVersionPeer::PRICE2, ProductVersionPeer::ECOTAX, ProductVersionPeer::NEWNESS, ProductVersionPeer::PROMO, ProductVersionPeer::STOCK, ProductVersionPeer::VISIBLE, ProductVersionPeer::WEIGHT, ProductVersionPeer::POSITION, ProductVersionPeer::CREATED_AT, ProductVersionPeer::UPDATED_AT, ProductVersionPeer::VERSION, ProductVersionPeer::VERSION_CREATED_AT, ProductVersionPeer::VERSION_CREATED_BY, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'REF', 'PRICE', 'PRICE2', 'ECOTAX', 'NEWNESS', 'PROMO', 'STOCK', 'VISIBLE', 'WEIGHT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'stock', 'visible', 'weight', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ProductVersionPeer::$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, 'Stock' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, 'VersionCreatedAt' => 15, 'VersionCreatedBy' => 16, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'stock' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, 'versionCreatedAt' => 15, 'versionCreatedBy' => 16, ),
+ BasePeer::TYPE_COLNAME => array (ProductVersionPeer::ID => 0, ProductVersionPeer::TAX_RULE_ID => 1, ProductVersionPeer::REF => 2, ProductVersionPeer::PRICE => 3, ProductVersionPeer::PRICE2 => 4, ProductVersionPeer::ECOTAX => 5, ProductVersionPeer::NEWNESS => 6, ProductVersionPeer::PROMO => 7, ProductVersionPeer::STOCK => 8, ProductVersionPeer::VISIBLE => 9, ProductVersionPeer::WEIGHT => 10, ProductVersionPeer::POSITION => 11, ProductVersionPeer::CREATED_AT => 12, ProductVersionPeer::UPDATED_AT => 13, ProductVersionPeer::VERSION => 14, ProductVersionPeer::VERSION_CREATED_AT => 15, ProductVersionPeer::VERSION_CREATED_BY => 16, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'PRICE' => 3, 'PRICE2' => 4, 'ECOTAX' => 5, 'NEWNESS' => 6, 'PROMO' => 7, 'STOCK' => 8, 'VISIBLE' => 9, 'WEIGHT' => 10, 'POSITION' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, 'VERSION_CREATED_AT' => 15, 'VERSION_CREATED_BY' => 16, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'stock' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, 'version_created_at' => 15, 'version_created_by' => 16, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
+ );
+
+ /**
+ * 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 = ProductVersionPeer::getFieldNames($toType);
+ $key = isset(ProductVersionPeer::$fieldKeys[$fromType][$name]) ? ProductVersionPeer::$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(ProductVersionPeer::$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, ProductVersionPeer::$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 ProductVersionPeer::$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. ProductVersionPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ProductVersionPeer::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(ProductVersionPeer::ID);
+ $criteria->addSelectColumn(ProductVersionPeer::TAX_RULE_ID);
+ $criteria->addSelectColumn(ProductVersionPeer::REF);
+ $criteria->addSelectColumn(ProductVersionPeer::PRICE);
+ $criteria->addSelectColumn(ProductVersionPeer::PRICE2);
+ $criteria->addSelectColumn(ProductVersionPeer::ECOTAX);
+ $criteria->addSelectColumn(ProductVersionPeer::NEWNESS);
+ $criteria->addSelectColumn(ProductVersionPeer::PROMO);
+ $criteria->addSelectColumn(ProductVersionPeer::STOCK);
+ $criteria->addSelectColumn(ProductVersionPeer::VISIBLE);
+ $criteria->addSelectColumn(ProductVersionPeer::WEIGHT);
+ $criteria->addSelectColumn(ProductVersionPeer::POSITION);
+ $criteria->addSelectColumn(ProductVersionPeer::CREATED_AT);
+ $criteria->addSelectColumn(ProductVersionPeer::UPDATED_AT);
+ $criteria->addSelectColumn(ProductVersionPeer::VERSION);
+ $criteria->addSelectColumn(ProductVersionPeer::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(ProductVersionPeer::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.PRICE');
+ $criteria->addSelectColumn($alias . '.PRICE2');
+ $criteria->addSelectColumn($alias . '.ECOTAX');
+ $criteria->addSelectColumn($alias . '.NEWNESS');
+ $criteria->addSelectColumn($alias . '.PROMO');
+ $criteria->addSelectColumn($alias . '.STOCK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.WEIGHT');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * 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(ProductVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(ProductVersionPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductVersionPeer::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 ProductVersion
+ * @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 = ProductVersionPeer::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 ProductVersionPeer::populateObjects(ProductVersionPeer::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(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ProductVersionPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductVersionPeer::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 ProductVersion $obj A ProductVersion 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->getVersion()));
+ } // if key === null
+ ProductVersionPeer::$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 ProductVersion 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 ProductVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+ } 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 ProductVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ProductVersionPeer::$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 ProductVersion 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(ProductVersionPeer::$instances[$key])) {
+ return ProductVersionPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool()
+ {
+ ProductVersionPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to product_version
+ * 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 + 14] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[$startcol], (string) $row[$startcol + 14]));
+ }
+
+ /**
+ * 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 + 14]);
+ }
+
+ /**
+ * 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 = ProductVersionPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ProductVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ProductVersionPeer::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;
+ ProductVersionPeer::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 (ProductVersion object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ProductVersionPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ProductVersionPeer::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 + ProductVersionPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ProductVersionPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ProductVersionPeer::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(ProductVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductVersionPeer::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 ProductVersion 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 ProductVersion 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(ProductVersionPeer::DATABASE_NAME);
+ }
+
+ ProductVersionPeer::addSelectColumns($criteria);
+ $startcol = ProductVersionPeer::NUM_HYDRATE_COLUMNS;
+ ProductPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ProductVersionPeer::ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = ProductVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductVersionPeer::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 (ProductVersion) to $obj2 (Product)
+ $obj2->addProductVersion($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(ProductVersionPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ProductVersionPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductVersionPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ProductVersionPeer::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 ProductVersion 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 ProductVersion 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(ProductVersionPeer::DATABASE_NAME);
+ }
+
+ ProductVersionPeer::addSelectColumns($criteria);
+ $startcol2 = ProductVersionPeer::NUM_HYDRATE_COLUMNS;
+
+ ProductPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ProductVersionPeer::ID, ProductPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ProductVersionPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ProductVersionPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = ProductVersionPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ProductVersionPeer::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 (ProductVersion) to the collection in $obj2 (Product)
+ $obj2->addProductVersion($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(ProductVersionPeer::DATABASE_NAME)->getTable(ProductVersionPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseProductVersionPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseProductVersionPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new ProductVersionTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass()
+ {
+ return ProductVersionPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ProductVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or ProductVersion 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(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ProductVersion object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductVersionPeer::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 ProductVersion or Criteria object.
+ *
+ * @param mixed $values Criteria or ProductVersion 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(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ProductVersionPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ProductVersionPeer::ID);
+ $value = $criteria->remove(ProductVersionPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ProductVersionPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ProductVersionPeer::TABLE_NAME);
+ }
+
+ $comparison = $criteria->getComparison(ProductVersionPeer::VERSION);
+ $value = $criteria->remove(ProductVersionPeer::VERSION);
+ if ($value) {
+ $selectCriteria->add(ProductVersionPeer::VERSION, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ProductVersionPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ProductVersion object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ProductVersionPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the product_version 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(ProductVersionPeer::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(ProductVersionPeer::TABLE_NAME, $con, ProductVersionPeer::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).
+ ProductVersionPeer::clearInstancePool();
+ ProductVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ProductVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ProductVersion 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(ProductVersionPeer::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.
+ ProductVersionPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof ProductVersion) { // it's a model object
+ // invalidate the cache for this single object
+ ProductVersionPeer::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(ProductVersionPeer::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(ProductVersionPeer::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ProductVersionPeer::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ // we can invalidate the cache for this single PK
+ ProductVersionPeer::removeInstanceFromPool($value);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductVersionPeer::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);
+ ProductVersionPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ProductVersion 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 ProductVersion $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(ProductVersionPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ProductVersionPeer::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(ProductVersionPeer::DATABASE_NAME, ProductVersionPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve object using using composite pkey values.
+ * @param int $id
+ * @param int $version
+ * @param PropelPDO $con
+ * @return ProductVersion
+ */
+ public static function retrieveByPK($id, $version, PropelPDO $con = null) {
+ $_instancePoolKey = serialize(array((string) $id, (string) $version));
+ if (null !== ($obj = ProductVersionPeer::getInstanceFromPool($_instancePoolKey))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $criteria = new Criteria(ProductVersionPeer::DATABASE_NAME);
+ $criteria->add(ProductVersionPeer::ID, $id);
+ $criteria->add(ProductVersionPeer::VERSION, $version);
+ $v = ProductVersionPeer::doSelect($criteria, $con);
+
+ return !empty($v) ? $v[0] : null;
+ }
+} // BaseProductVersionPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseProductVersionPeer::buildTableMap();
+
diff --git a/core/lib/Thelia/Model/om/BaseProductVersionQuery.php b/core/lib/Thelia/Model/om/BaseProductVersionQuery.php
new file mode 100644
index 000000000..e92a4a85c
--- /dev/null
+++ b/core/lib/Thelia/Model/om/BaseProductVersionQuery.php
@@ -0,0 +1,1045 @@
+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: [$id, $version]
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ProductVersion|ProductVersion[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ProductVersionPeer::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(ProductVersionPeer::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 ProductVersion A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `PRICE`, `PRICE2`, `ECOTAX`, `NEWNESS`, `PROMO`, `STOCK`, `VISIBLE`, `WEIGHT`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
+ 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 ProductVersion();
+ $obj->hydrate($row);
+ ProductVersionPeer::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 ProductVersion|ProductVersion[]|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|ProductVersion[]|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 ProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ProductVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ProductVersionPeer::VERSION, $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 ProductVersionQuery 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(ProductVersionPeer::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ProductVersionPeer::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $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
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @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 ProductVersionQuery 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(ProductVersionPeer::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
+ *
+ *
+ * @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 ProductVersionQuery 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(ProductVersionPeer::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxRuleId['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::PRICE, $price['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::PRICE2, $price2['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price2['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::PRICE2, $price2['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::ECOTAX, $ecotax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($ecotax['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($newness['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::NEWNESS, $newness['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::PROMO, $promo['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($promo['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::PROMO, $promo['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::PROMO, $promo, $comparison);
+ }
+
+ /**
+ * Filter the query on the stock column
+ *
+ * Example usage:
+ *
+ * $query->filterByStock(1234); // WHERE stock = 1234
+ * $query->filterByStock(array(12, 34)); // WHERE stock IN (12, 34)
+ * $query->filterByStock(array('min' => 12)); // WHERE stock > 12
+ *
+ *
+ * @param mixed $stock The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByStock($stock = null, $comparison = null)
+ {
+ if (is_array($stock)) {
+ $useMinMax = false;
+ if (isset($stock['min'])) {
+ $this->addUsingAlias(ProductVersionPeer::STOCK, $stock['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($stock['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::STOCK, $stock['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::STOCK, $stock, $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 ProductVersionQuery 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(ProductVersionPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($weight['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::WEIGHT, $weight['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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(ProductVersionPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version 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 ProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version) && null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt 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 ProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy 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 ProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $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 ProductVersionQuery 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(ProductVersionPeer::ID, $product->getId(), $comparison);
+ } elseif ($product instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductVersionPeer::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 ProductVersionQuery 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 ProductVersion $productVersion Object to remove from the list of results
+ *
+ * @return ProductVersionQuery The current query, for fluid interface
+ */
+ public function prune($productVersion = null)
+ {
+ if ($productVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ProductVersionPeer::ID), $productVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ProductVersionPeer::VERSION), $productVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/local/config/schema.xml b/local/config/schema.xml
index 055bc695a..7daff390d 100644
--- a/local/config/schema.xml
+++ b/local/config/schema.xml
@@ -14,6 +14,10 @@